Class BuilderUtils

java.lang.Object
org.xblackcat.sjpu.builder.BuilderUtils

public class BuilderUtils extends Object
30.06.2014 12:45
  • Field Details

    • EMPTY_LIST

      public static final javassist.CtClass[] EMPTY_LIST
  • Constructor Details

    • BuilderUtils

      public BuilderUtils()
  • Method Details

    • getName

      public static String getName(Class<?> clazz)
      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

      public static String getName(Type type)
    • checkArray

      protected static String checkArray(Class<?> clazz)
    • getName

      public static String getName(javassist.CtClass clazz)
      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

      public static String getUnwrapMethodName(javassist.CtClass returnType)
    • 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

      public static String asIdentifier(Class<?> typeMap)
    • asIdentifier

      public static String asIdentifier(Method mm)
    • getClassPool

      public static javassist.ClassPool getClassPool(javassist.ClassPool parent, Class<?> clazz, Class<?>... classes)
    • getClass

      public static Class<?> getClass(String fqn, javassist.ClassPool pool) throws ClassNotFoundException
      Throws:
      ClassNotFoundException
    • substituteTypeVariables

      public static Class<?> substituteTypeVariables(Map<TypeVariable<?>,Class<?>> map, Type typeToResolve)
    • resolveTypeVariables

      public static Map<TypeVariable<?>,Class<?>> resolveTypeVariables(Type type)
      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

      public static Method findDeclaredMethod(Class<?> root, Method m)
      Search method in specified class by signature of method.
      Parameters:
      root - class to search method in
      m - 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

      public static Method findDeclaredMethod(Class<?> root, Class<?> tillSuperClass, Method m)
      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 superclasses
      tillSuperClass - super class of root as bound for search. null value allows search through all superclass hierarchy of root class. To search
      m - 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

      public static String makeFieldName(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.
      Parameters:
      mName - getter method name
      Returns:
      field name related to the getter.
    • findGetter

      public static Method findGetter(Class<?> aClass, String fieldName)
    • isGetter

      public static boolean isGetter(Method m)
    • detectTypeArgClass

      public static Class<?> detectTypeArgClass(Type type)
    • detectTypeArgsClass

      public static Class<?>[] detectTypeArgsClass(Type type, int amount)
    • toJavaLiteral

      public static String toJavaLiteral(String str)
    • 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)