public class ClassUtils extends Object
| Constructor and Description |
|---|
ClassUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Type |
arrayType(Type service)
Find the Type of an array.
|
static Type |
collectionType(Type service)
Find the Type of collection.
|
static Collection |
createCollection(Class collectionCls,
Object[] data)
Given a collection type this method will return the appropied instance
for it.
|
static Map |
createMap(Class mapCls,
Object[] data)
Given a map type this method will return the appropied instance for it.
|
static Object |
createMultiple(Type service,
Object[] data)
Given a multiple type, (array, collection, or map) this method will
return the appropied instance for it.
|
static int |
findPriority(Class<?> cls)
Finds te priority value for a class, from it´s @Priority annotation if it
haveit.
|
static boolean |
hasGenericDeclaration(Type type)
Determines whenever the especified type has a wildcard or TypeVariable
declaration whiting.
|
static boolean |
isArray(Type service)
Determines whenever the passed type is an array.
|
static boolean |
isCollection(Type service)
Determines whenever the passed type is a collection.
|
static boolean |
isMap(Type service)
Determines whenever the passed type is a map.
|
static boolean |
isMultiple(Type service)
Determines whenever the passed type is an array, a java collection like
List or Set, or a java Map.
|
static Type |
mapType(Type service)
Find the Type of a map.
|
static Type |
multipleType(Type service)
Find the Type of an array, map or collection.
|
static Type |
parameterType(Type service,
int index)
Returns the specified parameter from the ParameterizedType.
|
static Class |
rawClass(Type service)
Gets the raw class for the especified Type.
|
static void |
sort(List<Class<?>> value)
Sorts a list of components by priority.
|
static Collection<Class<?>> |
toClasses(Collection instances)
Gets a collection with all the classes of the objects from the especified
collection.
|
static Type |
typeOf(WildcardType service)
Gets the upper bounds Type for a WildcarType.
|
public static Type typeOf(WildcardType service)
? extends SomeService = SomeService ? extends SomeService<String> = SomeService<String>
service - The wildcardType to inspect.public static Type multipleType(Type service)
SomeService[] = SomeService List<SomeService> = SomeService Map<Class, SomeService> = SomeService
service - The inner type of the multiple type passed.public static Type arrayType(Type service)
SomeService[] = SomeService
service - The inner type of the array type passed.public static Type collectionType(Type service)
List<SomeService> = SomeService Set<SomeService> = SomeService
service - The inner type of the array type passed.public static Type mapType(Type service)
Map<Class, SomeService> = SomeService HashMap<Class, SomeService> = SomeService
service - The inner type of the array type passed.public static Type parameterType(Type service, int index)
service - The ParameterizedType type to search the parameter.index - The index of the actual parameter.public static boolean isMultiple(Type service)
SomeService = false SomeService[] = true List<SomeService> = true Map<Class, SomeService> = true MyListImpl<SomeService> = false HashMap<Class, SomeService> = true
service - The type to inspect.public static boolean isArray(Type service)
SomeService = false SomeService[] = true List<SomeService> = false List<SomeService>[] = true Map<Class, SomeService> = false MyListImpl<SomeService> = false HashMap<Class, SomeService> = false
service - The type to inspect.public static boolean isCollection(Type service)
SomeService = false SomeService[] = false List<SomeService> = true List<SomeService>[] = true Map<Class, SomeService> = false MyListImpl<SomeService> = false HashMap<Class, SomeService> = false
service - The type to inspect.public static boolean isMap(Type service)
SomeService = false SomeService[] = false List<SomeService> = false List<SomeService>[] = false Map<Class, SomeService> = true MyListImpl<SomeService> = false HashMap<Class, SomeService> = true
service - The type to inspect.public static Class rawClass(Type service)
SomeService = SomeService SomeService[] = SomeService[] List<SomeService> = List List<SomeService>[] = List[] Map<Class, SomeService> = Map MyListImpl<SomeService> = MyListImpl HashMap<Class, SomeService> = HashMap
service - The type to take the raw class from.public static Collection<Class<?>> toClasses(Collection instances)
instances - The objects to obtain it´s classes from.public static int findPriority(Class<?> cls)
cls - The class to find it´s priority.public static Object createMultiple(Type service, Object[] data)
SomeService = null SomeService[] = SomeService[] List<SomeService> = ArrayList List<SomeService>[] = List[] Map<Class, SomeService> = Map MyListImpl<SomeService> = null HashMap<Class, SomeService> = HashMap
service - The type of the array, collection or map.data - The data to put on the result listing.public static Collection createCollection(Class collectionCls, Object[] data) throws InstantiationException, IllegalAccessException
SomeService = null SomeService[] = null List<SomeService> = ArrayList LinkedList<SomeService> = LinkedList List<SomeService>[] = null Map<Class, SomeService> = null MyListImpl<SomeService> = null HashMap<Class, SomeService> = null
collectionCls - The class for the collection.data - The data for the collection.InstantiationException - if the collection cannot be instance.IllegalAccessException - security exception.public static Map createMap(Class mapCls, Object[] data) throws InstantiationException, IllegalAccessException
SomeService = null SomeService[] = null List<SomeService> = null List<SomeService>[] = null Map<Class, SomeService> = Map MyListImpl<SomeService> = null HashMap<Class, SomeService> = HashMapl
mapCls - The clss for the map.data - The data for the map.InstantiationException - if the collection cannot be instance.IllegalAccessException - security exception.public static void sort(List<Class<?>> value)
value - The list of classes to sort.public static boolean hasGenericDeclaration(Type type)
SomeService<T> = true SomeService<?> = true SomeService = false SomeService<String> = false
type - The type to inspect.Copyright © 2015–2019 Bridje Framework. All rights reserved.