Class ReflectionUtil
java.lang.Object
org.eclipse.emf.mwe.internal.core.debug.mwe.ReflectionUtil
Provides static helper methods to deal with element fields using reflection.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
checkFields
(Object element) check if the element has member fields.getFieldNames
(Object element) returns a list of names of the fields.static Object
getFieldValue
(Object object, String name) Returns the value of a field of an object.
For primitives it returns a string representation.
It returns null in case of any exceptions.static String
getNameToString
(Object element) Null save toStringstatic String
getSimpleName
(Object element) return a String representation of the element.
-
Method Details
-
getSimpleName
return a String representation of the element. It is "null", the content of a String or the simple class name for all other types.
Hint: Primitives wrapper classes are not handled specially, so the result is not the primitive value but the class name. But since getFieldValue(..) returns a String representation of primitives, this should not be a problem here.- Parameters:
element
- the element- Returns:
- the string representation
-
getNameToString
Null save toString- Parameters:
element
- the element- Returns:
- the string representation
-
checkFields
check if the element has member fields. For an array it checks if it is not empty.- Parameters:
element
- the element- Returns:
- yes or no
-
getFieldNames
returns a list of names of the fields. For an array it returns "[i]" as name where i is the position in the array.- Parameters:
element
-- Returns:
- the list of field names
-
getFieldValue
Returns the value of a field of an object.
For primitives it returns a string representation.
It returns null in case of any exceptions.- Parameters:
object
- the questioned objectname
- the name of the field- Returns:
- the value
-