Package ftbsc.lll.utils
Class DescriptorBuilder
java.lang.Object
ftbsc.lll.utils.DescriptorBuilder
Builds a method descriptor for you.
See the documentation to better understand what this is.
Parameters must be given in a specific order.
Return type should always be specified for clarity, but defaults to void.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddParameter(Class<?> param) Adds a parameter of the given class type to the method.addParameter(String param) Adds a parameter with the type specified by the given fully qualified name to the method.addParameter(String param, int arrayLevel) Adds a parameter with the type specified by the given fully qualified name (example: java.lang.String) to the method, with the specified array level.build()Builds the descriptor into a string.static StringnameToDescriptor(String name, int arrayLevel) Converts a fully qualified name and array level to a descriptor.setReturnType(Class<?> returnType) Sets the return type to the given type.setReturnType(String returnType) Sets the return type to the Object specified here as a fully qualified name.setReturnType(String returnType, int arrayLevel) Sets the return type to the Object specified here as a fully qualified name (example: java.lang.String), with the specified array level.
-
Constructor Details
-
DescriptorBuilder
public DescriptorBuilder()Public constructor. Initialises default values.
-
-
Method Details
-
setReturnType
Sets the return type to the given type. Passing aClassmay cause problems if used with objects outside the Java SDK. Pass the fully qualified name as aStringrather than theClassobject for non-standard types.- Parameters:
returnType- the Class object corresponding to the return type- Returns:
- the builder's state after the change
-
setReturnType
Sets the return type to the Object specified here as a fully qualified name. Example: java.lang.String. No validity checks are performed: it's up to the user to ensure the name is correct.- Parameters:
returnType- the fully qualified name of the desired Object.- Returns:
- the builder's state after the change
-
setReturnType
Sets the return type to the Object specified here as a fully qualified name (example: java.lang.String), with the specified array level. No validity checks are performed: it's up to the user to ensure the name is correct.- Parameters:
returnType- the fully qualified name of the desired Object.arrayLevel- how many levels of array are there (example: String is 0, String[] is 1, String[][] is 2, etc.)- Returns:
- the builder's state after the change
-
addParameter
Adds a parameter of the given class type to the method. Parameter order matters. Passing aClassmay cause problems if used with objects outside the Java SDK. Pass the fully qualified name as aStringrather than theClassobject for non-standard types.- Parameters:
param- the Class object corresponding to the parameter- Returns:
- the builder's state after the change
-
addParameter
Adds a parameter with the type specified by the given fully qualified name to the method. Example: java.lang.String. Parameter order matters. No validity checks are performed: it's up to the user to ensure the name is correct.- Parameters:
param- the fully qualified name of the parameter type- Returns:
- the builder's state after the change
-
addParameter
Adds a parameter with the type specified by the given fully qualified name (example: java.lang.String) to the method, with the specified array level. Parameter order matters. No validity checks are performed: it's up to the user to ensure the name is correct.- Parameters:
param- the fully qualified name of the parameter typearrayLevel- how many levels of array are there (example: String is 0, String[] is 1, String[][] is 2, etc.)- Returns:
- the builder's state after the change
-
build
Builds the descriptor into a string. Example result:int m(Object[] o)becomes([Ljava/lang/Object;)I- Returns:
- the resulting descriptor
-
nameToDescriptor
Converts a fully qualified name and array level to a descriptor.- Parameters:
name- the fully qualified name of the object typearrayLevel- how many levels of array are there (example: String is 0, String[] is 1, String[][] is 2, etc.)- Returns:
- object descriptor
-