Klasse MethodNode
java.lang.Object
de.svws_nrw.transpiler.typescript.MethodNode
This class is used to store the information of transpiled java methods. This
information can be used to group java methods with the same name. For type script
such methods must have a common method body. This can be achieved using optional
parameters and union types for the implementation.
-
Konstruktorübersicht
KonstruktorBeschreibungMethodNode
(TranspilerTypeScriptPlugin plugin, ClassTree clazz, MethodTree method, String indent) Creates a new method with transpiled method information. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungReturns the access modifier of this methodgetBody()
Returns the method body without braces.Returns the transpiled and indented java commentgetName()
Returns the name of this methodgetParameter
(int i) Returns the name of the parameter specified by the index iint
Returns the number of parameters of this method.Returns the return type node of this methodboolean
Returns whether this method is a constructor or not.boolean
isStatic()
Returns whether the mthod is static or notvoid
print
(StringBuilder sb, String className) Prints the method using the specifiedStringBuilder
and the indent for this method.void
Prints the method head using the specifiedStringBuilder
and the indent for this method.static void
printImplementation
(StringBuilder sb, String indent, List<MethodNode> methods, String className) Prints the implementation of a method with multiple signaturesvoid
setAccessModifier
(String accessModifier) Sets the access modifier of this methodvoid
Sets the method bodystatic void
setCommonAccessModifier
(List<MethodNode> methods) Sets the less restrivtice common access modifer at the specified methods.
-
Konstruktordetails
-
MethodNode
public MethodNode(TranspilerTypeScriptPlugin plugin, ClassTree clazz, MethodTree method, String indent) Creates a new method with transpiled method information.- Parameter:
plugin
- theTranspilerTypeScriptPlugin
usedclazz
- the class this method belongs tomethod
- theMethodTree
object of the java compilerindent
- the indent to be used for formatting the method comment
-
-
Methodendetails
-
getReturnType
Returns the return type node of this method- Gibt zurück:
- the return type node or null for constructors
-
getName
Returns the name of this method- Gibt zurück:
- the name of this method
-
getComment
Returns the transpiled and indented java comment- Gibt zurück:
- the comment
-
getAccessModifier
Returns the access modifier of this method- Gibt zurück:
- the access modifier
-
setAccessModifier
Sets the access modifier of this method- Parameter:
accessModifier
- the access modifier
-
isStatic
public boolean isStatic()Returns whether the mthod is static or not- Gibt zurück:
- true if the method is static and false otherwise
-
isConstructor
public boolean isConstructor()Returns whether this method is a constructor or not.- Gibt zurück:
- true if this method is a constructor and false otherwise
-
getBody
Returns the method body without braces.- Gibt zurück:
- the method body.
-
setBody
Sets the method body- Parameter:
body
- the method body
-
printHead
Prints the method head using the specifiedStringBuilder
and the indent for this method. A body is not printed and the head ends with a semicolon.- Parameter:
sb
- theStringBuilder
-
getParameterCount
public int getParameterCount()Returns the number of parameters of this method.- Gibt zurück:
- the number of parameters of this method.
-
getParameter
Returns the name of the parameter specified by the index i- Parameter:
i
- the index number in the parameter list- Gibt zurück:
- the name of the parameter specified by the index i.
-
setCommonAccessModifier
Sets the less restrivtice common access modifer at the specified methods.- Parameter:
methods
- the methods
-
printImplementation
public static void printImplementation(StringBuilder sb, String indent, List<MethodNode> methods, String className) Prints the implementation of a method with multiple signatures- Parameter:
sb
- the StringBuilderindent
- the indent used to print the implementationmethods
- the list of methodsclassName
- the name of the class to be used in an enum constructor
-
print
Prints the method using the specifiedStringBuilder
and the indent for this method.- Parameter:
sb
- theStringBuilder
className
- the name of the class to be used in an enum constructor
-