public final class ReflectionExtensions extends Object
ReflectionExtensions.| Constructor and Description |
|---|
ReflectionExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static Field |
getDeclaredField(Class<?> cls,
String fieldName)
Gets the
Field that match to the given field name that exists in the given class. |
static <T> Field |
getDeclaredField(T object,
String fieldName)
Gets the
Field that match to the given field name that exists in the given object. |
static List<String> |
getFieldNames(Class<?> cls)
Gets all fieldnames from the given class as an String array.
|
static String[] |
getMethodNames(Class<?> cls)
Gets all methodnames from the given class as an String array.
|
static Map<String,String> |
getMethodNamesWithPrefixFromFieldNames(List<String> fieldNames,
String prefix)
Generates a Map with the fieldName as key and the method as value.
|
static List<String> |
getModifiers(Field field)
Gets the modifiers from the given Field as a list of String objects.
|
static <T> T |
getNewInstance(T obj)
Deprecated.
use instead
newInstance(Object) |
static <T> T |
newInstance(Class<T> clazz)
Creates a new instance from the same type as the given Class.
|
static <T> T |
newInstance(T obj)
Creates a new instance from the same type as the given object.
|
public static List<String> getFieldNames(Class<?> cls)
cls - The class object to get the fieldnames.public static String[] getMethodNames(Class<?> cls)
cls - The class object to get the methodnames.public static final Map<String,String> getMethodNamesWithPrefixFromFieldNames(List<String> fieldNames, String prefix)
fieldNames - A list with the fieldNames.prefix - The prefix for the methodname.public static List<String> getModifiers(Field field)
field - The field to get the modifiers.@Deprecated public static <T> T getNewInstance(T obj) throws ClassNotFoundException, InstantiationException, IllegalAccessException
newInstance(Object)T - the generic type of the given objectobj - the objClassNotFoundException - the class not found exceptionInstantiationException - the instantiation exceptionIllegalAccessException - the illegal access exceptionpublic static <T> T newInstance(T obj)
throws InstantiationException,
IllegalAccessException,
ClassNotFoundException
T - the generic typeobj - the objClassNotFoundException - the class not found exceptionInstantiationException - the instantiation exceptionIllegalAccessException - the illegal access exceptionpublic static <T> T newInstance(Class<T> clazz) throws InstantiationException, IllegalAccessException, ClassNotFoundException
T - the generic typeclazz - the Class objectClassNotFoundException - the class not found exceptionInstantiationException - the instantiation exceptionIllegalAccessException - the illegal access exceptionpublic static <T> Field getDeclaredField(T object, String fieldName) throws NoSuchFieldException, SecurityException
Field that match to the given field name that exists in the given object.T - the generic typeobject - the objectfieldName - the field nameNoSuchFieldException - is thrown if no such field exists.SecurityException - is thrown if a security manager says no.public static Field getDeclaredField(Class<?> cls, String fieldName) throws NoSuchFieldException, SecurityException
Field that match to the given field name that exists in the given class.cls - the clsfieldName - the field nameNoSuchFieldException - is thrown if no such field exists.SecurityException - is thrown if a security manager says no.Copyright © 2015–2017 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.