Package de.bild.codec
Class ReflectionHelper
java.lang.Object
de.bild.codec.ReflectionHelper
-
Method Summary
Modifier and TypeMethodDescriptioncalculateInferredTypeParameters(Class clazz, Type[] actualTypeParameters) Calculates the map of inferred type parameters for the given class based upon the given array of known type parameters from the class hierarchystatic ClassextractRawClass(Type type) static TypefindInterface(Type type, Class interfaceToFind) Example:static FieldTypePairgetDeclaredAndInheritedFieldTypePair(Type type, String fieldName) Finds a field with fully resolved type within the given typestatic List<FieldTypePair>getDeclaredAndInheritedFieldTypePairs(Type type, boolean returnFinalFields) calculates all fields of class hierarchystatic List<MethodTypePair>static FieldTypePairgetIdFieldIfPresent(Class clazz) static FieldTypePairstatic TypeinferRealType(Type type, Map<String, Type> realTypeMap)
-
Method Details
-
getDeclaredAndInheritedFieldTypePairs
public static List<FieldTypePair> getDeclaredAndInheritedFieldTypePairs(Type type, boolean returnFinalFields) calculates all fields of class hierarchy- Parameters:
type- the value typereturnFinalFields- indicate if final fields should be retuned as well- Returns:
- all declared and all inherited declared fields of given type
-
getDeclaredAndInheritedFieldTypePair
Finds a field with fully resolved type within the given type- Parameters:
type- any type generic or simply a classfieldName- a name of a field within that type- Returns:
- null, or the resolved FieldTypePair
-
calculateInferredTypeParameters
public static Map<String,Type> calculateInferredTypeParameters(Class clazz, Type[] actualTypeParameters) Calculates the map of inferred type parameters for the given class based upon the given array of known type parameters from the class hierarchy- Parameters:
clazz- the class to work onactualTypeParameters- array of type parameters- Returns:
- a Map of inferred types, that maps type variable names to real types
-
inferRealType
-
getDeclaredAndInheritedMethods
-
getIdFieldIfPresent
-
getLockingVersionFieldIfPresent
-
findInterface
Example:static class ValueClass {} static class SomeOtherClass<V extends ValueClass> extends ArrayList<V> implements List<V> {} static class SomeSpecializedList extends SomeOtherClass<ValueClass> {}- Parameters:
type- e.g. SomeSpecializedListinterfaceToFind- example List.class- Returns:
- the parameterized interface, e.g.
List<ValueClass>
-
extractRawClass
- Parameters:
type- type to be examined- Returns:
- The raw class of the given type or if type is a class, the class itself will be returned
-