Class ClassUtils

java.lang.Object
io.github.vitalforge.persistlib.util.ClassUtils

public final class ClassUtils extends Object
Utility class for operations on Class objects.
  • Method Details

    • isPrimitiveOrWrapper

      public static boolean isPrimitiveOrWrapper(Class<?> type)
      Checks if a class represents a primitive type or its corresponding wrapper type.
      Parameters:
      type - The class to check.
      Returns:
      true if the class represents a primitive type or its corresponding wrapper type, false otherwise.
    • isArgsValid

      public static boolean isArgsValid(Executable executable, Object[] args)
      Checks if the arguments are valid for a constructor.
      Parameters:
      executable - The method or constructor to check.
      args - The arguments to check.
      Returns:
      true if the arguments are valid for the constructor, false otherwise.
    • isCompatible

      public static boolean isCompatible(Class<?> parameterType, Class<?> argType)
      Checks if a parameter type is compatible with an argument type.
      Parameters:
      parameterType - The parameter type.
      argType - The argument type.
      Returns:
      true if the parameter type is compatible with the argument type, false otherwise.
    • castToRequiredType

      @NotNull public static <T> @NotNull Object castToRequiredType(@NotNull @NotNull Object object, Class<T> requiredType)
      Casts an object to the required type.
      Type Parameters:
      T - The required type.
      Parameters:
      object - The object to cast.
      requiredType - The required type.
      Returns:
      The object cast to the required type, or null if the object cannot be cast to the required type.