|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectit.avutils.jmapper.util.ClassesManager
public final class ClassesManager
Utility class that allows you to manage classes.
| Method Summary | ||
|---|---|---|
static boolean |
areEqual(Field destination,
Field source)
Returns true if destination and source have the same structure. |
|
static boolean |
areMappedObjects(Class<?> dClass,
Class<?> sClass,
XML xml)
returns true if almost one class is configured, false otherwise. |
|
static ChooseConfig |
configChosen(Class<?> dItem,
Class<?> sItem,
XML xml)
returns the location of the configuration, null if both classes are configured. |
|
static Class<?> |
defineStructure(Field destination,
Field source)
This method defines the destination structure for this operation. |
|
static boolean |
existField(Class<?> aClass,
String name)
Returns true if exist a field with this name in aClass, false otherwise. |
|
static List<Method> |
getAllMethods(Class<?> aClass)
Returns all methods that belongs to aClass. |
|
static List<Class<?>> |
getAllsuperclasses(Class<?> aClass)
Returns a list with the class passed in input plus his superclasses. |
|
static Class<?> |
getArrayItemClass(Field field)
Extracts the generic class from the type of field given as input. |
|
static Class<?> |
getCollectionItemClass(Field generic)
Extracts the generic class from the type of field given as input. |
|
static List<ConversionMethod> |
getConversionMethods(Class<?> clazz,
XML xml)
Returns the conversions method belonging to clazz. |
|
static
|
getFieldValue(Object obj,
String fieldName)
Extracts the value of a field from an object. |
|
static Class<?> |
getGenericMapKeyItem(Field generic)
Extracts the generic class from the type of field given as input. |
|
static Class<?> |
getGenericMapValueItem(Field generic)
Extracts the generic class from the type of field given as input. |
|
static String |
getGenericString(Field field)
|
|
static void |
getKeyValueClasses(Field field,
Class<?> key,
Class<?> value)
Classes key and value will be enhanced with the type of classes of the map. |
|
static List<Field> |
getListOfFields(Class<?> aClass)
Returns a List of aClass fields and all of its super classes. |
|
static Method |
getMethodOf(Class<?> clazz,
Field field)
Returns the getMethod of the field received in input. |
|
static Method |
getMethodOf(Class<?> clazz,
String field)
Returns the getMethod of the field received in input. |
|
static boolean |
isAddAllPermitted(Field destination,
Field source)
this method verify that the istruction: destination.addAll(source) is permitted |
|
static boolean |
isAssignableFrom(Class<?> destination,
Class<?> source)
Returns true if destination is assignable from source analyzing autoboxing also. |
|
static boolean |
isAssignableFrom(Field destination,
Field source)
this method verify that the instruction: destination = source
is permitted, checking their generics also |
|
static boolean |
isBoxing(Class<?> destination,
Class<?> source)
Returns true if is a boxing operation, false otherwise. |
|
static boolean |
isMapped(Class<?> aClass,
XML xml)
Returns true if the class is configured in annotation or xml, false otherwise. |
|
static boolean |
isMappedInAnnotation(Class<?> aClass)
Returns true if the class is configured in annotation, false otherwise. |
|
static boolean |
isMappedInXML(Class<?> aClass,
XML xml)
Returns true if the class is configured in xml, false otherwise. |
|
static boolean |
isPutAllPermitted(Field destination,
Field source)
this method verify that the istruction: destination.putAll(source) is permitted |
|
static boolean |
isUnBoxing(Class<?> destination,
Class<?> source)
Returns true if is an unboxing operation, false otherwise. |
|
static String |
mapperClassName(Class<?> destination,
Class<?> source,
String path)
Returns the name of mapper that identifies the destination and source classes. |
|
static Field |
retrieveField(Class<?> clazz,
String fieldName)
Returns a field with a specific name from class given as input. |
|
static Method |
setMethodOf(Class<?> clazz,
Field field)
Returns the setMethod of the field received in input. |
|
static Method |
setMethodOf(Class<?> clazz,
String field)
Returns the setMethod of the field received in input. |
|
static void |
verifiesAccessorMethods(Class<?> clazz,
Field... fields)
Verifies that the accessor methods are compliant with the naming convention. |
|
static void |
verifiesGetterMethods(Class<?> clazz,
Field... fields)
Verifies that the getter methods are compliant with the naming convention. |
|
static void |
verifySetterMethods(Class<?> clazz,
Field... fields)
Verifies that the setter methods are compliant with the naming convention. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean isPutAllPermitted(Field destination,
Field source)
destination.putAll(source)
is permitted
destination - source -
public static boolean isAddAllPermitted(Field destination,
Field source)
destination.addAll(source)
is permitted
destination - source -
public static boolean isAssignableFrom(Field destination,
Field source)
destination = source
is permitted, checking their generics also
destination - source -
public static boolean isAssignableFrom(Class<?> destination,
Class<?> source)
destination - source -
public static boolean isUnBoxing(Class<?> destination,
Class<?> source)
destination - the primitive Classsource - the Wrapper Class
public static boolean isBoxing(Class<?> destination,
Class<?> source)
destination - the Wrapper Classsource - the primitive Class
public static String getGenericString(Field field)
field -
public static boolean areEqual(Field destination,
Field source)
destination - source -
public static String mapperClassName(Class<?> destination,
Class<?> source,
String path)
destination - class of Destinationsource - class of Sourcepath - xml path
public static boolean existField(Class<?> aClass,
String name)
aClass - a class to controlname - field to find
public static boolean areMappedObjects(Class<?> dClass,
Class<?> sClass,
XML xml)
dClass - class to verifysClass - class to verify
public static boolean isMapped(Class<?> aClass,
XML xml)
aClass - a class
public static boolean isMappedInXML(Class<?> aClass,
XML xml)
aClass - a classxml - object
public static boolean isMappedInAnnotation(Class<?> aClass)
aClass - a class
public static List<Class<?>> getAllsuperclasses(Class<?> aClass)
aClass - class to check
public static List<Field> getListOfFields(Class<?> aClass)
aClass - class to handle
public static List<ConversionMethod> getConversionMethods(Class<?> clazz,
XML xml)
clazz - class to checkxml - xml object
public static List<Method> getAllMethods(Class<?> aClass)
aClass - class to check
public static Field retrieveField(Class<?> clazz,
String fieldName)
clazz - class to handlefieldName - name of field to retrieve
public static void verifiesAccessorMethods(Class<?> clazz,
Field... fields)
clazz - a class to checkfields - fields to control
public static void verifiesGetterMethods(Class<?> clazz,
Field... fields)
clazz - a class to checkfields - fields to control
public static void verifySetterMethods(Class<?> clazz,
Field... fields)
clazz - a class to checkfields - fields to control
public static ChooseConfig configChosen(Class<?> dItem,
Class<?> sItem,
XML xml)
dItem - class to analyzesItem - class to analyze
public static Method getMethodOf(Class<?> clazz,
String field)
clazz - class of the fieldfield -
public static Method setMethodOf(Class<?> clazz,
String field)
clazz - class of the fieldfield -
public static Method getMethodOf(Class<?> clazz,
Field field)
clazz - class of the fieldfield -
public static Method setMethodOf(Class<?> clazz,
Field field)
clazz - class of the fieldfield -
public static <T> T getFieldValue(Object obj,
String fieldName)
MyClass {
private String aField;
get and set...
}
String aFieldValue = getFieldValue(new MyClass("example"),"aField");
assertEqual("example",aFieldValue);
obj - fieldName -
public static Class<?> getCollectionItemClass(Field generic)
MyClass {
List<String> aList;
get and set...
}
Field aField = MyClass.class.getDeclaredField("aList");
Class> generic = getCollectionItemClass(aField);
assertEqual(generic,String.class);
generic - a Field
public static Class<?> getGenericMapKeyItem(Field generic)
MyClass {
Map<String, Integer> aMap;
get and set...
}
Field aField = MyClass.class.getDeclaredField("aMap");
Class> generic = getGenericMapKeyItem(aField);
assertEqual(generic,String.class);
generic - a Field
public static Class<?> getGenericMapValueItem(Field generic)
MyClass {
Map<String, Integer> aMap;
get and set...
}
Field aField = MyClass.class.getGenericMapValueItem("aMap");
Class> generic = getGenericMapKeyItem(aField);
assertEqual(generic,Integer.class);
generic - a Field
public static Class<?> getArrayItemClass(Field field)
MyClass {
MyObj[] anArray;
get and set...
}
Field aField = MyClass.class.getDeclaredField("anArray");
Class> item = getArrayItemClass(aField);
assertEqual(item,MyObj.class);
field - a Field
public static void getKeyValueClasses(Field field,
Class<?> key,
Class<?> value)
field - of type mapkey - class of the mapvalue - class of the map
public static Class<?> defineStructure(Field destination,
Field source)
destination - destination fieldsource - source field
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||