java.lang.Object
org.springaicommunity.mcp.method.tool.utils.ClassUtils

public abstract class ClassUtils extends Object
  • Constructor Details

    • ClassUtils

      public ClassUtils()
  • Method Details

    • isPrimitiveWrapper

      public static boolean isPrimitiveWrapper(Class<?> clazz)
      Check if the given class represents a primitive wrapper, i.e. Boolean, Byte, Character, Short, Integer, Long, Float, Double, or Void.
      Parameters:
      clazz - the class to check
      Returns:
      whether the given class is a primitive wrapper class
    • isPrimitiveOrWrapper

      public static boolean isPrimitiveOrWrapper(Class<?> clazz)
      Check if the given class represents a primitive (i.e. boolean, byte, char, short, int, long, float, or double), void, or a wrapper for those types (i.e. Boolean, Byte, Character, Short, Integer, Long, Float, Double, or Void).
      Parameters:
      clazz - the class to check
      Returns:
      true if the given class represents a primitive, void, or a wrapper class
    • resolvePrimitiveIfNecessary

      public static Class<?> resolvePrimitiveIfNecessary(Class<?> clazz)
      Resolve the given class if it is a primitive class, returning the corresponding primitive wrapper type instead.
      Parameters:
      clazz - the class to check
      Returns:
      the original class, or a primitive wrapper for the original primitive type
    • isVoidType

      public static boolean isVoidType(Class<?> type)
      Determine if the given type represents either Void or void.
      Parameters:
      type - the type to check
      Returns:
      true if the type represents Void or void
      Since:
      6.1.4
      See Also:
    • isSimpleValueType

      public static boolean isSimpleValueType(Class<?> type)
      Delegate for org.springframework.beans.BeanUtils#isSimpleValueType. Also used by ObjectUtils#nullSafeConciseToString.

      Check if the given type represents a common "simple" value type: primitive or primitive wrapper, Enum, String or other CharSequence, Number, Date, Temporal, ZoneId, TimeZone, File, Path, URI, URL, InetAddress, Charset, Currency, Locale, UUID, Pattern, or Class.

      Void and void are not considered simple value types.

      Parameters:
      type - the type to check
      Returns:
      whether the given type represents a "simple" value type, suggesting value-based data binding and toString output
      Since:
      6.1
    • isAssignable

      public static boolean isAssignable(Class<?> lhsType, Class<?> rhsType)
      Check if the right-hand side type may be assigned to the left-hand side type, assuming setting by reflection. Considers primitive wrapper classes as assignable to the corresponding primitive types.
      Parameters:
      lhsType - the target type (left-hand side (LHS) type)
      rhsType - the value type (right-hand side (RHS) type) that should be assigned to the target type
      Returns:
      true if rhsType is assignable to lhsType
      See Also:
      • TypeUtils#isAssignable(java.lang.reflect.Type, java.lang.reflect.Type)