public class IntrospectionUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
getCapitalizedName(String fieldName)
Capitalizes the given field name.
|
static <T> Constructor<T> |
getConstructor(Class<T> clazz,
Class<?>... parameterTypes)
Returns a public constructor of the given class with the given parameter
types.
|
static PropertyMetadata |
getPropertyMetadata(Field field)
Returns the meatdata for the given field.
|
static Method |
getReadMethod(Class<?> clazz,
String readMethodName,
Class<?> expectedReturnType)
Gets the method object with the given name and return type.
|
static Method |
getReadMethod(PropertyMetadata propertyMetadata)
Returns the read method for the given property.
|
static Method |
getReadMethod(PropertyMetadata propertyMetadata,
String readMethodName)
Returns the Method object that allows reading of the given property.
|
static String |
getReadMethodName(Field field)
Returns the name of the method that can be used to read the given field.
|
static String |
getReadMethodNameForBoolean(Field field)
Returns the name of the method that can be used to read the given boolean
field.
|
static Method |
getWriteMethod(Class<?> clazz,
String writeMethodName,
Class<?> parameterType)
Returns the write method with the given name and parameter type.
|
static Method |
getWriteMethod(PropertyMetadata propertyMetadata)
Returns the write method(setter method) for the given property.
|
static String |
getWriteMethodName(Field field)
Returns the name of the method that can be used to write (or set) the
given field.
|
static Object |
initializeEmbedded(EmbeddedMetadata embeddedMetadata,
Object target)
Initializes the Embedded object represented by the given metadata.
|
static Object |
instantiateObject(Class<?> clazz)
Creates a new object of given class by invoking the class' default public
constructor.
|
static Class<?>[] |
resolveCollectionType(Type type)
Examines the given Collection type (List and Set) and returns the Class
and Parameterized type, if any.
|
static Class<?>[] |
resolveMapType(Type type)
Examines the given Map type and returns the raw type, type of keys, type
of values in the map.
|
public static PropertyMetadata getPropertyMetadata(Field field)
field
- the field whose metadata has to be preparedpublic static Method getReadMethod(PropertyMetadata propertyMetadata)
propertyMetadata
- the property metadata.public static Method getReadMethod(Class<?> clazz, String readMethodName, Class<?> expectedReturnType)
clazz
- the class that is supposed to have the specified methodreadMethodName
- the method nameexpectedReturnType
- the return typepublic static Method getReadMethod(PropertyMetadata propertyMetadata, String readMethodName)
propertyMetadata
- the property metadatareadMethodName
- the method name (e.g. getXXX or isXXX).public static Method getWriteMethod(PropertyMetadata propertyMetadata)
propertyMetadata
- the propertypublic static Method getWriteMethod(Class<?> clazz, String writeMethodName, Class<?> parameterType)
clazz
- The class that is supposed to have the specified method.writeMethodName
- the method nameparameterType
- the parameter type.public static String getReadMethodName(Field field)
field
- the fieldpublic static String getReadMethodNameForBoolean(Field field)
field
- the field namepublic static String getWriteMethodName(Field field)
field
- the name of the fieldpublic static String getCapitalizedName(String fieldName)
fieldName
- the field namepublic static Object instantiateObject(Class<?> clazz)
clazz
- the class whose instance needs to be createdEntityManagerException
- if any error occurspublic static Object initializeEmbedded(EmbeddedMetadata embeddedMetadata, Object target)
embeddedMetadata
- the metadata of the embedded fieldtarget
- the object in which the embedded field is declared/accessible
fromEntityManagerException
- if any error occurs during initialization of the embedded
objectpublic static Class<?>[] resolveCollectionType(Type type)
type
- the Collection typenull
.public static Class<?>[] resolveMapType(Type type)
type
- the type of mapnull
null
public static <T> Constructor<T> getConstructor(Class<T> clazz, Class<?>... parameterTypes)
null
, if there is no matching constructor.clazz
- the classparameterTypes
- expected types of parametersnull
, if there is
no matching constructor.Copyright © 2016. All rights reserved.