Package com.github.jasminb.jsonapi
Class ReflectionUtils
- java.lang.Object
-
- com.github.jasminb.jsonapi.ReflectionUtils
-
public class ReflectionUtils extends Object
Various utility methods that simplify JAVA reflection actions.- Author:
- jbegic
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<Field>getAnnotatedFields(Class<?> clazz, Class<? extends Annotation> annotation, boolean checkSuperclass)Returns all field from a given class that are annotated with provided annotation type.static Class<?>getFieldType(Field field)static StringgetTypeName(Class<?> clazz)Returns the type name defined using Type annotation on provided class.
-
-
-
Method Detail
-
getAnnotatedFields
public static List<Field> getAnnotatedFields(Class<?> clazz, Class<? extends Annotation> annotation, boolean checkSuperclass)
Returns all field from a given class that are annotated with provided annotation type.- Parameters:
clazz- source classannotation- target annotationcheckSuperclass- if true, method will follow class hierarchy to look for fields with target annotation- Returns:
- list of fields or empty collection in case no fields were found
-
getTypeName
public static String getTypeName(Class<?> clazz)
Returns the type name defined using Type annotation on provided class.- Parameters:
clazz- type class- Returns:
- name of the type or
nullin case Type annotation is not present
-
-