Class InspectionData


  • public class InspectionData
    extends Object
    Represents all data available for the inspection for a class
    Author:
    Tim Neumann
    • Constructor Detail

      • InspectionData

        public InspectionData​(Class<?> cls)
        Creates a new inspection data object for the given class
        Parameters:
        cls - The class to create a inspection data object for.
    • Method Detail

      • getAttributeValue

        public Object getAttributeValue​(Object obj,
                                        String name)
        Get the value of the attribute with the given name from the given object.
        Parameters:
        obj - The object to get the value from
        name - The name of the attribute to get the value from
        Returns:
        The value
      • setAttributeValue

        public boolean setAttributeValue​(Object obj,
                                         String name,
                                         Object value)
        Set's the value of the attribute with the given name for the given object
        Parameters:
        obj - The object to set the value in.
        name - The name of the attribute to set.
        value - The value to set.
        Returns:
        Whether it worked.
      • getAttributeNames

        public List<String> getAttributeNames()
        Get the attribute names of the class for this inspection data.
        Returns:
        A list of attribute names.
      • getAttributeType

        public Class<?> getAttributeType​(String attributeName)
        Get the type of the attribute with the given name.
        Parameters:
        attributeName - The name of the attribute
        Returns:
        The type of the attribute.
      • isAttributeReadOnly

        public boolean isAttributeReadOnly​(String attributeName)
        Check whether the attribute with the given name is read only.
        Parameters:
        attributeName - The name of the attribute.
        Returns:
        Whether the attribute is read only.
      • hasAnyInspectableElements

        public boolean hasAnyInspectableElements()
        Returns:
        Whether this inspection data has any inspectable elements.
      • getMethodNames

        public List<String> getMethodNames()
        Get the mathod names of the class for this inspection data.
        Returns:
        A list of method names.
      • getMethodByName

        public Method getMethodByName​(String methodName)
        Get the method detail for the method with the given name
        Parameters:
        methodName - The name of the method to get the detail for
        Returns:
        The method detail.
      • invokeMethod

        public Object invokeMethod​(Object obj,
                                   String methodName,
                                   Object... args)
        Invoke the method with the given name in the given object, using the given arguments
        Parameters:
        obj - The object to call the method on
        methodName - The name of the method to call
        args - The arguments to use
        Returns:
        The return value.