Class DefaultJavaMethod

    • Constructor Detail

      • DefaultJavaMethod

        public DefaultJavaMethod()
        The default constructor
      • DefaultJavaMethod

        public DefaultJavaMethod​(java.lang.String name)
        Create new method without parameters and return type
        Parameters:
        name - the name of the method
      • DefaultJavaMethod

        public DefaultJavaMethod​(JavaClass returns,
                                 java.lang.String name)
        Create a new method without parameters
        Parameters:
        returns - the return type
        name - the name of this method
    • Method Detail

      • isDefault

        public boolean isDefault()
        Equivalent Method.isDefault()
        Specified by:
        isDefault in interface JavaMethod
        Returns:
        true if this is a default method of an interface, otherwise false
      • setDefault

        public void setDefault​(boolean defaultMethod)
      • getCodeBlock

        public java.lang.String getCodeBlock()
        Specified by:
        getCodeBlock in interface JavaModel
        Returns:
        the codeblock
      • getDeclarationSignature

        public java.lang.String getDeclarationSignature​(boolean withModifiers)
        Specified by:
        getDeclarationSignature in interface JavaMethod
        Parameters:
        withModifiers - true if modifiers should be added, otherwise false
        Returns:
        the declaration signature
      • setReturns

        public void setReturns​(JavaClass returns)
        Define the return type of this method
        Parameters:
        returns - the return type
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • isPropertyAccessor

        public boolean isPropertyAccessor()
        Returns true if this method follows the bean convention of being an accessor.
           public String getName();             // true
           public boolean isValid()             // true
           public String getName( String def ); // false, it has a parameter
           public String gettingUp();           // false, 'get' is not followed by an uppercase character
           public boolean isolate();            // false, 'is' is not followed by an uppercase character
           public static String getName();      // false, it is static
         
        Specified by:
        isPropertyAccessor in interface JavaMethod
        Returns:
        true if this method is a Java Bean accessor, otherwise false
      • isPropertyMutator

        public boolean isPropertyMutator()
        Returns true if this method follows the bean convention of being an mutator.
          public void setName(String name);        // true
          public void setUp();                     // false, it has no parameter
          public void settingUp(String def);       // false, 'set' is not followed by an uppercase character
          public static void setName(String name); // false, it is static
         
        Specified by:
        isPropertyMutator in interface JavaMethod
        Returns:
        true if this method is a Java Bean mutator, otherwise false
      • getPropertyType

        public JavaType getPropertyType()
        Specified by:
        getPropertyType in interface JavaMethod
        Returns:
        the type of the property this method represents, or null if this method is not a property mutator or property accessor.
      • getPropertyName

        public java.lang.String getPropertyName()
        Specified by:
        getPropertyName in interface JavaMethod
        Returns:
        the name of the property this method represents, or null if this method is not a property mutator or property accessor.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getReturnType

        public JavaType getReturnType()
        Equivalent of java.lang.reflect.Method.getReturnType()
        Specified by:
        getReturnType in interface JavaMethod
        Returns:
        the return type
      • getReturnType

        public JavaType getReturnType​(boolean resolve)
        If a class inherits this method from a generic class or interface, you can use this method to get the resolved return type
        Specified by:
        getReturnType in interface JavaMethod
        Parameters:
        resolve - define if generic should be resolved
        Returns:
        the return type
      • signatureMatches

        public boolean signatureMatches​(java.lang.String name,
                                        java.util.List<JavaType> parameterTypes)
        This method is NOT varArg aware.
        Specified by:
        signatureMatches in interface JavaMethod
        Parameters:
        name - the name of the method
        parameterTypes - the parameter types of the method, can be null
        Returns:
        true if this method matches the signature, otherwise false
      • signatureMatches

        public boolean signatureMatches​(java.lang.String name,
                                        java.util.List<JavaType> parameterTypes,
                                        boolean varArg)
        Specified by:
        signatureMatches in interface JavaMethod
        Parameters:
        name - the name of the method
        parameterTypes - the parameter types, can be null
        varArg - true is signature should match a varArg-method, otherwise false
        Returns:
        true if this method matches the signature, otherwise false