Class ClassUtils

java.lang.Object
org.apache.juneau.internal.ClassUtils

public final class ClassUtils extends Object
Class-related utility methods.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getClasses

      public static Class<?>[] getClasses(Object... args)
      Returns the class types for the specified arguments.
      Parameters:
      args - The objects we're getting the classes of.
      Returns:
      The classes of the arguments.
    • getMatchingArgs

      public static Object[] getMatchingArgs(Class<?>[] paramTypes, Object... args)
      Matches arguments to a list of parameter types.

      Extra parameters are ignored.
      Missing parameters are left null.

      Parameters:
      paramTypes - The parameter types.
      args - The arguments to match to the parameter types.
      Returns:
      An array of parameters.
    • setAccessible

      public static boolean setAccessible(Constructor<?> x)
      Attempts to call x.setAccessible(true) and quietly ignores security exceptions.
      Parameters:
      x - The constructor.
      Returns:
      true if call was successful.
    • setAccessible

      public static boolean setAccessible(Method x)
      Attempts to call x.setAccessible(true) and quietly ignores security exceptions.
      Parameters:
      x - The method.
      Returns:
      true if call was successful.
    • setAccessible

      public static boolean setAccessible(Field x)
      Attempts to call x.setAccessible(true) and quietly ignores security exceptions.
      Parameters:
      x - The field.
      Returns:
      true if call was successful.
    • toClass

      public static Class<?> toClass(Type t)
      Returns the specified type as a Class.

      If it's already a Class, it just does a cast.
      If it's a ParameterizedType, it returns the raw type.

      Parameters:
      t - The type to convert.
      Returns:
      The type converted to a Class, or null if it could not be converted.
    • className

      public static String className(Object value)
      Returns the fully-qualified class name for the specified object.
      Parameters:
      value - The object to get the class name for.
      Returns:
      The name of the class or null if the value was null.
    • simpleClassName

      public static String simpleClassName(Object value)
      Returns the simple class name for the specified object.
      Parameters:
      value - The object to get the class name for.
      Returns:
      The name of the class or null if the value was null.
    • isVoid

      public static boolean isVoid(Class c)
      Returns true if the specific class is null or void.class or Void or has the simple name "Void.
      Parameters:
      c - The class to check.
      Returns:
      true if the specific class is null or void.class or Void or has the simple name "Void.
    • isNotVoid

      public static boolean isNotVoid(Class c)
      Returns false if the specific class is null or void.class or Void or has the simple name "Void.
      Parameters:
      c - The class to check.
      Returns:
      false if the specific class is null or void.class or Void or has the simple name "Void.