public final class PodamUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
private static String |
GETTER_PREFIX |
private static String |
GETTER_PREFIX2 |
private static org.slf4j.Logger |
LOG
The application logger.
|
static char[] |
NICE_ASCII_CHARACTERS
An array of valid String characters
|
private static int |
SETTER_IDENTIFIER_LENGTH |
| Modifier | Constructor and Description |
|---|---|
private |
PodamUtils()
Non instantiable constructor
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
containsAnyAnnotation(Field field,
Set<Class<? extends Annotation>> annotations)
Checks if the given field has any one of the annotations
|
private static boolean |
containsAnyAnnotation(Method method,
Set<Class<? extends Annotation>> annotations)
Checks if the given method has any one of the annotations
|
static String |
extractFieldNameFromGetterMethod(Method method)
Given a getter
Method, it extracts the field name, according to
JavaBean standards |
static String |
extractFieldNameFromSetterMethod(Method method)
Given a setter
Method, it extracts the field name, according to
JavaBean standards |
static void |
fillPojoSets(Class<?> clazz,
Set<Field> classFields,
Set<Method> classGetters,
Set<Method> classSetters,
Set<Class<? extends Annotation>> excludeAnnotations,
Set<String> excludedFields)
Given a class and a set of class declared fields it returns a Set of
setters, getters and fields defined for this class
|
static List<Annotation> |
getAttributeAnnotations(Field attribute,
Method setter)
Given the attribute and setter it combines annotations from them
or an empty collection if no custom annotations were found
|
static ClassInfo |
getClassInfo(Class<?> clazz,
ClassAttributeApprover attributeApprover)
It returns a
ClassInfo object for the given class |
static ClassInfo |
getClassInfo(Class<?> clazz,
Set<Class<? extends Annotation>> excludeFieldAnnotations,
Set<String> excludedFields,
ClassAttributeApprover attributeApprover)
It returns a
ClassInfo object for the given class |
static ClassInfo |
getClassInfo(Class<?> clazz,
Set<Class<? extends Annotation>> excludeFieldAnnotations,
Set<String> excludedFields,
ClassAttributeApprover attributeApprover,
Collection<Method> extraMethods) |
static Field |
getField(Class<?> pojoClass,
String attributeName)
It returns a
Field matching the attribute name or null if a field
was not found. |
static <T> T |
getFieldValue(Object pojo,
String attributeName)
It returns an value for a
Field matching the attribute
name or null if a field was not found. |
static long |
getLongInRange(long minValue,
long maxValue)
It returns a long/Long value between min and max value (included).
|
static Character |
getNiceCharacter()
Generates random character from set valid for identifiers in Java language
|
static Class<?> |
primitiveToBoxedType(Class<?> primitiveType)
Finds boxed type for a primitive type
|
private static final int SETTER_IDENTIFIER_LENGTH
private static final String GETTER_PREFIX
private static final String GETTER_PREFIX2
public static final char[] NICE_ASCII_CHARACTERS
private static final org.slf4j.Logger LOG
public static ClassInfo getClassInfo(Class<?> clazz, ClassAttributeApprover attributeApprover)
ClassInfo object for the given classclazz - The class to retrieve info fromattributeApprover - a ClassAttributeApprover implementation,
which attributes to skip and which to process.
If one hasn't been provided, Podam will use the
default one in the DefaultClassInfoStrategy class.ClassInfo object for the given classpublic static ClassInfo getClassInfo(Class<?> clazz, Set<Class<? extends Annotation>> excludeFieldAnnotations, Set<String> excludedFields, ClassAttributeApprover attributeApprover)
ClassInfo object for the given classclazz - The class to retrieve info fromexcludeFieldAnnotations - the fields marked with any of these annotations will not be
included in the class infoexcludedFields - the fields matching the given names will not be included in the class infoattributeApprover - a ClassAttributeApprover implementation,
which defines which attributes to skip and which to processClassInfo object for the given classpublic static ClassInfo getClassInfo(Class<?> clazz, Set<Class<? extends Annotation>> excludeFieldAnnotations, Set<String> excludedFields, ClassAttributeApprover attributeApprover, Collection<Method> extraMethods)
public static boolean containsAnyAnnotation(Field field, Set<Class<? extends Annotation>> annotations)
field - the field to check forannotations - the set of annotations to look for in the fieldprivate static boolean containsAnyAnnotation(Method method, Set<Class<? extends Annotation>> annotations)
method - the method to check forannotations - the set of annotations to look for in the fieldpublic static void fillPojoSets(Class<?> clazz, Set<Field> classFields, Set<Method> classGetters, Set<Method> classSetters, Set<Class<? extends Annotation>> excludeAnnotations, Set<String> excludedFields)
Anything present: setter, getter or field will be recorded as three independent sets available for future analysis
clazz - The class to analyze for settersclassFields - The Set which will be filled with class' fieldsclassGetters - The Set which will be filled with class' gettersclassSetters - The Set which will be filled with class' settersexcludeAnnotations - The Set containing annotations marking fields to be excludedexcludedFields - The Set containing field names to be excludedpublic static String extractFieldNameFromSetterMethod(Method method)
Method, it extracts the field name, according to
JavaBean standards
This method, given a setter method, it returns the corresponding attribute name. For example: given setIntField the method would return intField. The correctness of the return value depends on the adherence to JavaBean standards.
method - The setter method from which the field name is requiredpublic static String extractFieldNameFromGetterMethod(Method method)
Method, it extracts the field name, according to
JavaBean standards
This method, given a getter method, it returns the corresponding attribute name. For example: given getIntField the method would return intField; given isBoolField the method would return boolField. The correctness of the return value depends on the adherence to JavaBean standards.
method - The setter method from which the field name is requiredpublic static Field getField(Class<?> pojoClass, String attributeName)
Field matching the attribute name or null if a field
was not found.pojoClass - The class supposed to contain the fieldattributeName - The field nameField matching the attribute name or null if a field
was not found.public static <T> T getFieldValue(Object pojo, String attributeName)
Field matching the attribute
name or null if a field was not found.T - The type of field to be returnedpojo - The class supposed to contain the fieldattributeName - The field nameField matching the attribute name or
null if a field was not found.public static List<Annotation> getAttributeAnnotations(Field attribute, Method setter)
attribute - The class attributesetter - The class attribute'sĀ setterpublic static Character getNiceCharacter()
public static long getLongInRange(long minValue,
long maxValue)
minValue - The minimum value for the returned valuemaxValue - The maximum value for the returned valueCopyright © 2015. All rights reserved.