Class MethodReference2

  • All Implemented Interfaces:
    EventListener, IGProp<GProp<?>[]>, IPropCnr, java.lang.Cloneable
    Direct Known Subclasses:
    EditorMethodReference2, FieldActor

    public class MethodReference2
    extends PropCnr
    The Method Reference "2" property class hold the reference to a Method that is in a Java class.

    Two variants are supported:

    1. As for classic MethodReference:
      a Java class reference "ClassReference" is held by a parent container in the tree, and this method reference is a simple name without '.' and is the method in the class.
    2. a static method reference in a class, where this name is the fully qualified class name with the method name last.
    Author:
    Christopher Mindus
    • Field Detail

      • requiredAnnotations

        protected java.lang.String requiredAnnotations
        The required annotation, or null for none.
      • runtimeMethod

        protected java.lang.reflect.Method runtimeMethod
        The method for runtime, null for none.
    • Constructor Detail

      • MethodReference2

        protected MethodReference2()
        Creates a Method Reference property with no name and with a null value.
      • MethodReference2

        public MethodReference2​(Atom propertyAtom)
        Creates a Method Reference property with the specified name with a null value.
        Parameters:
        propertyAtom - the property atom.
      • MethodReference2

        public MethodReference2​(Atom propertyAtom,
                                java.lang.String reference)
        Creates a Class Reference property with the specified name and value.
        Parameters:
        propertyAtom - the property atom.
        reference - the reference string.
    • Method Detail

      • isStatic

        public boolean isStatic()
        Checks if this is a static reference, i.e. has a name with a '.' inside.
      • setMethodName

        public boolean setMethodName​(java.lang.String method)
        Sets the method name.
        Parameters:
        method - The method name as "method" if instance, "class.method" if static, empty string for none.
        Returns:
        true for changed, false for no change.
      • setMethodName

        public boolean setMethodName​(java.lang.String method,
                                     IComplexOperation op)
        Sets the method name.
        Parameters:
        method - The method name as "method" if instance, "class.method" if static, empty string or null for none.
        op - The complex operation for undo/redo.
        Returns:
        true for changed, false for no change.
      • getMethodName

        public java.lang.String getMethodName()
        Gets the method name, instance or static.
        Returns:
        The method name as "method" if instance, "class.method" if static, empty string for none.
      • equalsErrors

        protected boolean equalsErrors​(PropError pe1,
                                       PropError pe2,
                                       int how)
        Processes error property verification. The default processing is to verify the two error properties pe1 and pe2 for equality if includeErrors is 0 or 1, and returns true if the value is 2=no comparison with error properties.

        Override to verify property errors for reference properties.

        Overrides:
        equalsErrors in class GProp<GProp<?>[]>
        Parameters:
        pe1 - The first error property, may be null.
        pe2 - The second error property, may be null.
        how - Flags EQC_* values for equal checking.
        Returns:
        Equality flag depending on includeErrors value.
      • initializeElement

        protected void initializeElement​(org.w3c.dom.Element element)
        Called when the XML file for the property tree is serialized from properties. The property should fill attributes and nodes with appropriate information.
        Overrides:
        initializeElement in class PropCnr
        Parameters:
        element - The Element to initialize.
      • initializeProp

        public void initializeProp​(org.w3c.dom.Element element)
                            throws PropException
        Called to initialize the property from an Element. The property should initialize itself from attributes and nodes with appropriate information.
        Overrides:
        initializeProp in class PropCnr
        Parameters:
        element - The Element.
        Throws:
        PropException - when the initialization fails.
      • getRuntimeMethod

        public java.lang.reflect.Method getRuntimeMethod()
        Gets the loaded method for runtime.
        Returns:
        The loaded method, or null for none.
      • onPrepare

        protected void onPrepare​(IAppOwner appOwner,
                                 IModuleOwner moduleOwner,
                                 boolean isPostCall,
                                 java.util.List<java.lang.Throwable> errors)
                          throws PropException
        Called when the application is being prepared. The order of onPrepare calls is always parent first, the children. The method is called twice, first time with isPostCall set to false, then a second time with true.
        Overrides:
        onPrepare in class GProp<GProp<?>[]>
        Parameters:
        appOwner - The application owner.
        moduleOwner - The Module owner.
        isPostCall - Flag indicating this is a post-call.
        errors - A list of errors that occurred but did not cause an abort.
        Throws:
        PropException - For property errors during the application preparation to need to abort.
      • lookupMethod

        public java.lang.reflect.Method lookupMethod​(ClassReference classReference,
                                                     java.util.List<java.lang.Throwable> errors,
                                                     java.lang.Class<?>... parameterTypes)
        Called when the application is being prepared by the owner of the method reference to look-up the method with the specified parameters.
        Parameters:
        classReference - The class reference instance, or null for static methods.
        errors - A list of errors that occurred but did not cause an abort.
        parameterTypes - The list of parameters.