java.lang.Object | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | - | - | java.lang.reflect.AccessibleObject | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | - | - | java.lang.reflect.Field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
A Field provides information about a field of a class or an interface.
Get the field modifiers, name and type
Return | Method | Summary |
---|---|---|
int | getModifiers() | Returns the Java language modifiers for the field. |
String | getName() | Returns the name of the field. |
Class<?> | getType() | Returns a Class object that identifies the declared type. |
Is this field an Enum, is it Synthetic
Return | Method | Summary |
---|---|---|
boolean | isEnumConstant() | Returns true if this field represents an element of an enumerated type; returns false otherwise. |
boolean | isSynthetic() | Returns true if this field is a synthetic field; returns false otherwise. |
Get annotation for this field
Return | Method | Summary |
---|---|---|
<T extends Annotation>T | getAnnotation(Class<T> annotationClass) | Returns this element's annotation. |
Annotation[] | getDeclaredAnnotations() | Returns all annotations that are directly present on this element. |
Get the class for this field
Return | Method | Summary |
---|---|---|
Class<?> | getDeclaringClass() | Returns the Class object representing the class or interface that declares the field. |
Get field value with Reflection
Return | Method | Summary |
---|---|---|
Object | get(Object obj) | Returns field value |
boolean | getBoolean(Object obj) | Gets field value as boolean. |
byte | getByte(Object obj) | Gets field value as byte. |
char | getChar(Object obj) | Gets field value as char. |
double | getDouble(Object obj) | Gets field value as double. |
float | getFloat(Object obj) | Gets field value as float. |
Type | getGenericType() | Returns a Type object that represents the declared type for the field represented by this Field object. |
int | getInt(Object obj) | Gets field value as int. |
long | getLong(Object obj) | Gets field value as long. |
short | getShort(Object obj) | Gets field value as short. |
Set field value with Reflection
Return | Method | Summary |
---|---|---|
void | set(Object obj, Object value) | Sets the field value. |
void | setBoolean(Object obj, boolean z) | Sets boolean field value. |
void | setByte(Object obj, byte b) | Sets byte field value. |
void | setChar(Object obj, char c) | Sets char field value. |
void | setDouble(Object obj, double d) | Sets double field value. |
void | setFloat(Object obj, float f) | Sets float field value. |
void | setInt(Object obj, int i) | Sets int field value. |
void | setLong(Object obj, long l) | Sets long field value. |
void | setShort(Object obj, short s) | Sets short field value. |
Get the string representation of a field
Return | Method | Summary |
---|---|---|
String | toGenericString() | Returns a string describing this Field, including its generic type. |
String | toString() | Returns a string describing this Field. |
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |