Class DefaultJavaMethod

All Implemented Interfaces:
JavaAnnotatedElement, JavaExecutable, JavaGenericDeclaration, JavaMember, JavaMethod, JavaModel, Serializable

public class DefaultJavaMethod extends DefaultJavaExecutable implements JavaMethod
See Also:
  • Field Details

  • Constructor Details

    • DefaultJavaMethod

      public DefaultJavaMethod()
      The default constructor
    • DefaultJavaMethod

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

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

    • isDefault

      public boolean 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)
    • getReturns

      public JavaClass getReturns()
      Specified by:
      getReturns in interface JavaMethod
      Overrides:
      getReturns in class DefaultJavaExecutable
      Returns:
      the return type
    • setTypeParameters

      public void setTypeParameters(List<JavaTypeVariable<JavaMethod>> typeParameters)
    • getTypeParameters

      public List<JavaTypeVariable<JavaMethod>> getTypeParameters()
      Specified by:
      getTypeParameters in interface JavaGenericDeclaration
      Returns:
      a list of typeParameters, never null
    • getCodeBlock

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

      public 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(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class 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 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 String toString()
      Overrides:
      toString in class 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(String name, 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(String name, 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