Class ReflectionUtil

java.lang.Object
org.eclipse.emf.mwe.internal.core.debug.mwe.ReflectionUtil

public class ReflectionUtil extends Object
Provides static helper methods to deal with element fields using reflection.
  • Method Details

    • getSimpleName

      public static String getSimpleName(Object element)
      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

      public static String getNameToString(Object element)
      Null save toString
      Parameters:
      element - the element
      Returns:
      the string representation
    • checkFields

      public static boolean checkFields(Object element)
      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

      public static List<String> getFieldNames(Object element)
      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

      public 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.
      Parameters:
      object - the questioned object
      name - the name of the field
      Returns:
      the value