java.lang.Object
ru.progrm_jarvis.javacommons.classloading.ClassUtil

public final class ClassUtil extends Object
Utility for class-related stuff.
  • Method Details

    • isPrimitiveWrapper

      public static boolean isPrimitiveWrapper(Class<?> clazz)
      Checks if the given class is a primitive wrapper.
      Parameters:
      clazz - class to check
      Returns:
      true if the class is a primitive wrapper and false otherwise
    • toPrimitiveWrapper

      @NotNull public static @NotNull Class<?> toPrimitiveWrapper(@NotNull @NotNull Class<?> primitiveClass)
      Gets a primitive-wrapper class for the given primitive class.
      Parameters:
      primitiveClass - primitive class whose wrapper is needed
      Returns:
      primitive-wrapper class for the given primitive class
      Throws:
      IllegalArgumentException - if the given class is not primitive
    • toNonPrimitive

      @NotNull public static @NotNull Class<?> toNonPrimitive(@NotNull @NotNull Class<?> originalClass)
      Either returns a primitive-wrapper class for the given one if it is primitive or the provided class otherwise.
      Parameters:
      originalClass - class whose wrapper should be returned on demand
      Returns:
      primitive-wrapper class for the given class if it is primitive or the provided class otherwise
    • toPrimitive

      public static Class<?> toPrimitive(@NotNull @NotNull Class<?> primitiveWrapperClass)
      Gets a primitive class for the given primitive-wrapper class.
      Parameters:
      primitiveWrapperClass - primitive-wrapper class whose wrapper is needed
      Returns:
      primitive class for the given primitive-wrapper class
      Throws:
      IllegalArgumentException - if the given class is not a primitive-wrapper
    • integrateType

      public static Class<?> integrateType(@NotNull @NotNull Class<?> original, @NotNull @NotNull Class<?> target)

      Integrates the original type with the target making so that target type should be assignable from integrated one (i.e., attempting to make the original type a sub-class of the target type)

      This method performs primitive-to-wrapper conversion in oder to attempt integration.

      Parameters:
      original - original type which should be integrated to the target type
      target - target type to which the original type should be integrated
      Returns:
      result of type integration, my be the same as original type
      Throws:
      IllegalArgumentException - if original type cannot be integrated to the target type
    • classDigger

      @NotNull public static @NotNull Function<? super @NotNull Class<?>,@NotNull Stream<? extends @NotNull Class<?>>> classDigger(boolean interfaces)
      Creates a class-digger for use with Recursions API which digs the class hierarchy.
      Parameters:
      interfaces - whether interfaces should be considered
      Returns:
      digger which returns a stream of super-classes and implemented interfaces (optionally) of the provided class
    • classDiggerWithoutInterfaces

      @NotNull public static @NotNull Function<? super @NotNull Class<?>,@NotNull Stream<? extends @NotNull Class<?>>> classDiggerWithoutInterfaces()
      Creates a class-digger for use with Recursions API which digs the class hierarchy only including super-classes.
      Returns:
      digger which returns a stream of super-classes of the provided class
    • classDiggerWithInterfaces

      @NotNull public static @NotNull Function<? super @NotNull Class<?>,@NotNull Stream<? extends @NotNull Class<?>>> classDiggerWithInterfaces()
      Creates a class-digger for use with Recursions API which digs the class hierarchy including super-classes and parent interfaces.
      Returns:
      digger which returns a stream of super-classes and implemented interfaces of the provided class