Package org.xblackcat.sjpu.builder
Class BuilderUtils
java.lang.Object
org.xblackcat.sjpu.builder.BuilderUtils
30.06.2014 12:45
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringasIdentifier(Class<?> typeMap) static StringasIdentifier(Method mm) protected static StringcheckArray(Class<?> clazz) static Class<?>detectTypeArgClass(Type type) static Class<?>[]detectTypeArgsClass(Type type, int amount) static MethodfindDeclaredMethod(Class<?> root, Class<?> tillSuperClass, Method m) Search method in specified class by signature of method.static MethodfindDeclaredMethod(Class<?> root, Method m) Search method in specified class by signature of method.static MethodfindGetter(Class<?> aClass, String fieldName) static Class<?>static javassist.ClassPoolgetClassPool(javassist.ClassPool parent, Class<?> clazz, Class<?>... classes) static StringReturns full qualified name of the class in java-source form: inner class names separates with dot ('.') instead of dollar sign ('$')static Stringstatic StringgetName(javassist.CtClass clazz) Returns full qualified name of the class in java-source form: inner class names separates with dot ('.') instead of dollar sign ('$')static StringgetUnwrapMethodName(javassist.CtClass returnType) static booleanstatic StringmakeFieldName(String mName) Generate a field name by getter method name: trims 'is' or 'get' at the beginning and convert to lower case the first letter.static Map<TypeVariable<?>,Class<?>> resolveTypeVariables(Type type) Method for resolving classes for all available type variables for the given typestatic <T extends Enum<T>>
TsearchForEnum(Class<T> clazz, String name) static Class<?>substituteTypeVariables(Map<TypeVariable<?>, Class<?>> map, Type typeToResolve) static <T> StringtoArrayJavaCode(Function<T, String> argToJava, Class<T> elementClass, Collection<T> list) static <T> StringtoArrayJavaCode(Function<T, String> argToJava, Class<T> elementClass, T... args) static javassist.CtClassstatic javassist.CtClass[]toCtClasses(javassist.ClassPool pool, Class<?>... classes) static StringtoJavaLiteral(String str)
-
Field Details
-
EMPTY_LIST
public static final javassist.CtClass[] EMPTY_LIST
-
-
Constructor Details
-
BuilderUtils
public BuilderUtils()
-
-
Method Details
-
getName
Returns full qualified name of the class in java-source form: inner class names separates with dot ('.') instead of dollar sign ('$')- Parameters:
clazz- class to get FQN- Returns:
- full qualified name of the class in java-source form
-
getName
-
checkArray
-
getName
Returns full qualified name of the class in java-source form: inner class names separates with dot ('.') instead of dollar sign ('$')- Parameters:
clazz- class to get FQN- Returns:
- full qualified name of the class in java-source form
-
getUnwrapMethodName
-
toCtClasses
public static javassist.CtClass[] toCtClasses(javassist.ClassPool pool, Class<?>... classes) throws javassist.NotFoundException - Throws:
javassist.NotFoundException
-
toCtClass
public static javassist.CtClass toCtClass(javassist.ClassPool pool, Class<?> clazz) throws javassist.NotFoundException - Throws:
javassist.NotFoundException
-
asIdentifier
-
asIdentifier
-
getClassPool
-
getClass
- Throws:
ClassNotFoundException
-
substituteTypeVariables
public static Class<?> substituteTypeVariables(Map<TypeVariable<?>, Class<?>> map, Type typeToResolve) -
resolveTypeVariables
Method for resolving classes for all available type variables for the given type- Parameters:
type- querying type- Returns:
- map with existing type variables as keys with Class object if the target class is resolved.
-
findDeclaredMethod
Search method in specified class by signature of method.- Parameters:
root- class to search method inm- method as signature source.- Returns:
- method of the specified class with the same signature or null if the class has no method with the signature
-
findDeclaredMethod
Search method in specified class by signature of method. Search through superclasses till specified super class (exclude).- Parameters:
root- class to search method in and its superclassestillSuperClass- super class of root as bound for search.nullvalue allows search through all superclass hierarchy of root class. To searchm- method as signature source.- Returns:
- method of the specified class with the same signature or null if the class has no method with the signature
-
searchForEnum
public static <T extends Enum<T>> T searchForEnum(Class<T> clazz, String name) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
makeFieldName
Generate a field name by getter method name: trims 'is' or 'get' at the beginning and convert to lower case the first letter.- Parameters:
mName- getter method name- Returns:
- field name related to the getter.
-
findGetter
-
isGetter
-
detectTypeArgClass
-
detectTypeArgsClass
-
toJavaLiteral
-
toArrayJavaCode
@SafeVarargs public static <T> String toArrayJavaCode(Function<T, String> argToJava, Class<T> elementClass, T... args) -
toArrayJavaCode
public static <T> String toArrayJavaCode(Function<T, String> argToJava, Class<T> elementClass, Collection<T> list)
-