Class JavaMethod

java.lang.Object
com.github.tadukoo.java.method.JavaMethod
All Implemented Interfaces:
JavaCodeType, JavaTokens
Direct Known Subclasses:
EditableJavaMethod, UneditableJavaMethod

public abstract class JavaMethod extends Object implements JavaCodeType
Java Method represents a method in a Java class or interface, etc.
Since:
Alpha v.0.2 (as old version that is now more like UneditableJavaMethod), Alpha v.0.4 (as newer version)
Version:
Beta v.0.5
Author:
Logan Ferree (Tadukoo)
  • Field Details

    • javadoc

      protected Javadoc javadoc
      The Javadoc on the method
    • annotations

      protected List<JavaAnnotation> annotations
      The annotations on the method
    • visibility

      protected Visibility visibility
      The Visibility of the method
    • isAbstract

      protected boolean isAbstract
      Whether the method is abstract or not
    • isStatic

      protected boolean isStatic
      Whether the method is static or not
    • isFinal

      protected boolean isFinal
      Whether the method is final or not
    • returnType

      protected String returnType
      The return type of the method
    • name

      protected String name
      The name of the method
    • parameters

      protected List<com.github.tadukoo.util.tuple.Pair<String,String>> parameters
      The parameters used in the method - pairs of type, then name
    • throwTypes

      protected List<String> throwTypes
      The types that can be thrown by the method
    • lines

      protected List<String> lines
      The actual lines of code in the method
  • Constructor Details

    • JavaMethod

      protected JavaMethod(boolean editable, Javadoc javadoc, List<JavaAnnotation> annotations, Visibility visibility, boolean isAbstract, boolean isStatic, boolean isFinal, String returnType, String name, List<com.github.tadukoo.util.tuple.Pair<String,String>> parameters, List<String> throwTypes, List<String> lines)
      Constructs a new Java Method with the given parameters
      Parameters:
      editable - Whether the method is editable or not
      javadoc - The Javadoc on the method
      annotations - The annotations on the method
      visibility - The Visibility of the method
      isAbstract - Whether the method is abstract or not
      isStatic - Whether the method is static or not
      isFinal - Whether the method is final or not
      returnType - The return type of the method
      name - The name of the method
      parameters - The parameters used in the method - pairs of type, then name
      throwTypes - The types that can be thrown by the method
      lines - The actual lines of code in the method
  • Method Details

    • getJavaCodeType

      public JavaCodeTypes getJavaCodeType()
      Specified by:
      getJavaCodeType in interface JavaCodeType
      Returns:
      What type this is
    • isEditable

      public boolean isEditable()
      Returns:
      Whether the method is editable or not
    • getJavadoc

      public Javadoc getJavadoc()
      Returns:
      The Javadoc on the method
    • getAnnotations

      public List<JavaAnnotation> getAnnotations()
      Returns:
      The annotations on the method
    • getVisibility

      public Visibility getVisibility()
      Returns:
      The Visibility of the method
    • isAbstract

      public boolean isAbstract()
      Returns:
      Whether the method is abstract or not
    • isStatic

      public boolean isStatic()
      Returns:
      Whether the method is static or not
    • isFinal

      public boolean isFinal()
      Returns:
      Whether the method is final or not
    • getReturnType

      public String getReturnType()
      Returns:
      The return type of the method
    • getName

      public String getName()
      Returns:
      The name of the method
    • getUniqueName

      public String getUniqueName()
      Builds and returns a unique name for the method. This is for use when a class has multiple methods with the same base name, but different parameters.

      If a method has no parameters, this will return a name of the form methodName()

      If a method does have parameters, they will appear in the parentheses with a comma and space after each but the last parameter, in the form methodName(parameter1Type parameter1Name, parameter2Type parameter2Name

      If the method is a constructor, it will appear with the name init, e.g. init() or init(parameter1Type parameter1Name)
      Returns:
      A unique name for the method
    • getParameters

      public List<com.github.tadukoo.util.tuple.Pair<String,String>> getParameters()
      Returns:
      The parameters used in the method - pairs of type, then name
    • getThrowTypes

      public List<String> getThrowTypes()
      Returns:
      The types that can be thrown by the method
    • getLines

      public List<String> getLines()
      Returns:
      The actual lines of code in the method
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      This Java Method as a String, ready to be put in some Java code
    • equals

      public boolean equals(Object otherMethod)
      Overrides:
      equals in class Object
    • toBuilderCode

      public String toBuilderCode()
      Specified by:
      toBuilderCode in interface JavaCodeType
      Returns:
      The String of code to build the JavaCodeType