Package com.github.tadukoo.java.method
Class JavaMethod
java.lang.Object
com.github.tadukoo.java.method.JavaMethod
- All Implemented Interfaces:
JavaCodeType,JavaTokens
- Direct Known Subclasses:
EditableJavaMethod,UneditableJavaMethod
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.6
- Author:
- Logan Ferree (Tadukoo)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<JavaAnnotation>Theannotationson the methodprotected booleanWhether the method is abstract or notprotected booleanWhether the method is final or notprotected booleanWhether the method is static or notprotected JavadocTheJavadocon the methodThe actual lines of code in the methodprotected StringThe name of the methodprotected List<JavaParameter>Theparametersused in the methodprotected JavaTypeThe returntypeof the methodThe types that can be thrown by the methodprotected List<JavaTypeParameter>Anytype parameterson the methodprotected VisibilityTheVisibilityof the methodFields inherited from interface com.github.tadukoo.java.JavaCodeType
NEWLINE_WITH_2_TABS, NEWLINE_WITH_4_TABSFields inherited from interface com.github.tadukoo.java.JavaTokens
ABSTRACT_MODIFIER, ANNOTATION_START_TOKEN, ASSIGNMENT_OPERATOR_TOKEN, BLOCK_CLOSE_TOKEN, BLOCK_OPEN_TOKEN, CLASS_TOKEN, EXTENDS_TOKEN, FINAL_MODIFIER, IMPLEMENTS_TOKEN, IMPORT_TOKEN, JAVADOC_AUTHOR_TOKEN, JAVADOC_LINE_TOKEN, JAVADOC_PARAM_TOKEN, JAVADOC_RETURN_TOKEN, JAVADOC_SINCE_TOKEN, JAVADOC_START_TOKEN, JAVADOC_VERSION_TOKEN, LIST_SEPARATOR_TOKEN, MODIFIERS, MULTI_LINE_COMMENT_CLOSE_TOKEN, MULTI_LINE_COMMENT_START_TOKEN, PACKAGE_TOKEN, PARAMETER_CLOSE_TOKEN, PARAMETER_OPEN_TOKEN, PRIVATE_MODIFIER, PROTECTED_MODIFIER, PUBLIC_MODIFIER, SEMICOLON, SINGLE_LINE_COMMENT_TOKEN, STATIC_MODIFIER, THROWS_TOKEN, TYPE_PARAMETER_CLOSE_TOKEN, TYPE_PARAMETER_OPEN_TOKEN, VARARGS_TOKEN, VISIBILITY_MODIFIERS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJavaMethod(boolean editable, Javadoc javadoc, List<JavaAnnotation> annotations, Visibility visibility, boolean isAbstract, boolean isStatic, boolean isFinal, List<JavaTypeParameter> typeParameters, JavaType returnType, String name, List<JavaParameter> parameters, List<String> throwTypes, List<String> lines) Constructs a new Java Method with the given parameters -
Method Summary
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.github.tadukoo.java.JavaCodeType
escapeQuotes
-
Field Details
-
javadoc
TheJavadocon the method -
annotations
Theannotationson the method -
visibility
TheVisibilityof the method -
isAbstract
protected boolean isAbstractWhether the method is abstract or not -
isStatic
protected boolean isStaticWhether the method is static or not -
isFinal
protected boolean isFinalWhether the method is final or not -
typeParameters
Anytype parameterson the method -
returnType
The returntypeof the method -
name
The name of the method -
parameters
Theparametersused in the method -
throwTypes
The types that can be thrown by the method -
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, List<JavaTypeParameter> typeParameters, JavaType returnType, String name, List<JavaParameter> parameters, List<String> throwTypes, List<String> lines) Constructs a new Java Method with the given parameters- Parameters:
editable- Whether the method is editable or notjavadoc- TheJavadocon the methodannotations- Theannotationson the methodvisibility- TheVisibilityof the methodisAbstract- Whether the method is abstract or notisStatic- Whether the method is static or notisFinal- Whether the method is final or nottypeParameters- Anytype parameterson the methodreturnType- The returntypeof the methodname- The name of the methodparameters- Theparametersused in the methodthrowTypes- The types that can be thrown by the methodlines- The actual lines of code in the method
-
-
Method Details
-
getJavaCodeType
- Specified by:
getJavaCodeTypein interfaceJavaCodeType- Returns:
- What
typethis is
-
isEditable
public boolean isEditable()- Returns:
- Whether the method is editable or not
-
getJavadoc
- Returns:
- The
Javadocon the method
-
getAnnotations
- Returns:
- The
annotationson the method
-
getVisibility
- Returns:
- The
Visibilityof 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
-
getTypeParameters
- Returns:
- Any
type parametersfor the method
-
getReturnType
- Returns:
- The return
typeof the method
-
getName
- Returns:
- The name of the method
-
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 formmethodName()
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 formmethodName(parameter1Type parameter1Name, parameter2Type parameter2Name
If the method is a constructor, it will appear with the nameinit, e.g.init()orinit(parameter1Type parameter1Name)- Returns:
- A unique name for the method
-
getParameters
- Returns:
- The
parametersused in the method
-
getThrowTypes
- Returns:
- The types that can be thrown by the method
-
getLines
- Returns:
- The actual lines of code in the method
-
toString
-
equals
-
toBuilderCode
- Specified by:
toBuilderCodein interfaceJavaCodeType- Returns:
- The String of code to build the
JavaCodeType
-