Package uk.co.jemos.podam.api
Class PodamUtils
- java.lang.Object
-
- uk.co.jemos.podam.api.PodamUtils
-
public abstract class PodamUtils extends Object
PODAM Utilities class.- Since:
- 1.0.0
- Author:
- mtedone
-
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.LoggerLOGThe application logger.static char[]NICE_ASCII_CHARACTERSAn array of valid String characters
-
Constructor Summary
Constructors Constructor Description PodamUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<Annotation>getAttributeAnnotations(Field attribute, Method... methods)Given the attribute and setter it combines annotations from them or an empty collection if no custom annotations were foundstatic doublegetDoubleInRange(double minValue, double maxValue)It returns a double/Double value between min and max value (included).static FieldgetField(Class<?> pojoClass, String attributeName)It returns aFieldmatching the attribute name or null if a field was not found.static <T> TgetFieldValue(Object pojo, String attributeName)It returns an value for aFieldmatching the attribute name or null if a field was not found.static <T> TgetFieldValueWithGetter(Object pojo, String attributeName)It returns an value from getter for aFieldmatching the attribute name or null if a field was not found.static intgetIntegerInRange(int minValue, int maxValue)It returns a random int/Integer value between min and max value (included).static longgetLongInRange(long minValue, long maxValue)It returns a long/Long value between min and max value (included).static CharactergetNiceCharacter()Generates random character from set valid for identifiers in Java languagestatic Class<?>primitiveToBoxedType(Class<?> primitiveType)Finds boxed type for a primitive typestatic MethodselectLatestMethod(Set<Method> methods)Searches among set of a class'es methods and selects the one defined in the most specific descend of the hierarchy tree
-
-
-
Method Detail
-
getField
public static Field getField(Class<?> pojoClass, String attributeName)
It returns aFieldmatching the attribute name or null if a field was not found.- Parameters:
pojoClass- The class supposed to contain the fieldattributeName- The field name- Returns:
- a
Fieldmatching the attribute name or null if a field was not found.
-
getFieldValue
public static <T> T getFieldValue(Object pojo, String attributeName)
It returns an value for aFieldmatching the attribute name or null if a field was not found.- Type Parameters:
T- The type of field to be returned- Parameters:
pojo- The class supposed to contain the fieldattributeName- The field name- Returns:
- an instance of
Fieldmatching the attribute name or null if a field was not found.
-
getFieldValueWithGetter
public static <T> T getFieldValueWithGetter(Object pojo, String attributeName)
It returns an value from getter for aFieldmatching the attribute name or null if a field was not found.- Type Parameters:
T- The type of field to be returned- Parameters:
pojo- The class supposed to contain the fieldattributeName- The field name- Returns:
- an instance of
Fieldmatching the attribute name or null if a field was not found.
-
selectLatestMethod
public static Method selectLatestMethod(Set<Method> methods)
Searches among set of a class'es methods and selects the one defined in the most specific descend of the hierarchy tree- Parameters:
methods- a set of methods to choose from- Returns:
- the selected method
-
getAttributeAnnotations
public static List<Annotation> getAttributeAnnotations(Field attribute, Method... methods)
Given the attribute and setter it combines annotations from them or an empty collection if no custom annotations were found- Parameters:
attribute- The class attributemethods- List of setters and getter to check annotations- Returns:
- all annotations for the attribute
-
getNiceCharacter
public static Character getNiceCharacter()
Generates random character from set valid for identifiers in Java language- Returns:
- random character suitable for identifier
-
getLongInRange
public static long getLongInRange(long minValue, long maxValue)It returns a long/Long value between min and max value (included).- Parameters:
minValue- The minimum value for the returned valuemaxValue- The maximum value for the returned value- Returns:
- A long/Long value between min and max value (included).
-
getIntegerInRange
public static int getIntegerInRange(int minValue, int maxValue)It returns a random int/Integer value between min and max value (included).- Parameters:
minValue- The minimum value for the returned valuemaxValue- The maximum value for the returned value- Returns:
- An int/Integer value between min and max value (included).
-
getDoubleInRange
public static double getDoubleInRange(double minValue, double maxValue)It returns a double/Double value between min and max value (included).- Parameters:
minValue- The minimum value for the returned valuemaxValue- The maximum value for the returned value- Returns:
- A double/Double value between min and max value (included)
-
-