Package ftbsc.lll.utils
Class DescriptorBuilder
- java.lang.Object
-
- ftbsc.lll.utils.DescriptorBuilder
-
public class DescriptorBuilder extends java.lang.Object
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 Constructor Description DescriptorBuilder()
Public constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DescriptorBuilder
addParameter(java.lang.Class<?> param)
Adds a parameter of the given class type to the method.DescriptorBuilder
addParameter(java.lang.String param)
Adds a parameter with the type specified by the given fully qualified name to the method.DescriptorBuilder
addParameter(java.lang.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.java.lang.String
build()
Builds the descriptor into a string.static java.lang.String
nameToDescriptor(java.lang.String name, int arrayLevel)
Converts a fully qualified name and array level to a descriptor.DescriptorBuilder
setReturnType(java.lang.Class<?> returnType)
Sets the return type to the given type.DescriptorBuilder
setReturnType(java.lang.String returnType)
Sets the return type to the Object specified here as a fully qualified name.DescriptorBuilder
setReturnType(java.lang.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.
-
-
-
Method Detail
-
setReturnType
public DescriptorBuilder setReturnType(java.lang.Class<?> returnType)
Sets the return type to the given type. Passing aClass
may cause problems if used with objects outside the Java SDK. Pass the fully qualified name as aString
rather than theClass
object for non-standard types.- Parameters:
returnType
- the Class object corresponding to the return type- Returns:
- the builder's state after the change
-
setReturnType
public DescriptorBuilder setReturnType(java.lang.String returnType)
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
public DescriptorBuilder setReturnType(java.lang.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. 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
public DescriptorBuilder addParameter(java.lang.Class<?> param)
Adds a parameter of the given class type to the method. Parameter order matters. Passing aClass
may cause problems if used with objects outside the Java SDK. Pass the fully qualified name as aString
rather than theClass
object for non-standard types.- Parameters:
param
- the Class object corresponding to the parameter- Returns:
- the builder's state after the change
-
addParameter
public DescriptorBuilder addParameter(java.lang.String param)
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
public DescriptorBuilder addParameter(java.lang.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. 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
public java.lang.String build()
Builds the descriptor into a string. Example result:int m(Object[] o)
becomes([Ljava/lang/Object;)I
- Returns:
- the resulting descriptor
-
nameToDescriptor
public static java.lang.String nameToDescriptor(java.lang.String name, int arrayLevel)
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
-
-