Class ClassUtils
java.lang.Object
org.springaicommunity.mcp.method.tool.utils.ClassUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisAssignable(Class<?> lhsType, Class<?> rhsType) Check if the right-hand side type may be assigned to the left-hand side type, assuming setting by reflection.static booleanisPrimitiveOrWrapper(Class<?> clazz) Check if the given class represents a primitive (i.e.static booleanisPrimitiveWrapper(Class<?> clazz) Check if the given class represents a primitive wrapper, i.e.static booleanisSimpleValueType(Class<?> type) Delegate fororg.springframework.beans.BeanUtils#isSimpleValueType.static booleanisVoidType(Class<?> type) Determine if the given type represents eitherVoidorvoid.static Class<?>resolvePrimitiveIfNecessary(Class<?> clazz) Resolve the given class if it is a primitive class, returning the corresponding primitive wrapper type instead.
-
Constructor Details
-
ClassUtils
public ClassUtils()
-
-
Method Details
-
isPrimitiveWrapper
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
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:
trueif the given class represents a primitive, void, or a wrapper class
-
resolvePrimitiveIfNecessary
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
Determine if the given type represents eitherVoidorvoid. -
isSimpleValueType
Delegate fororg.springframework.beans.BeanUtils#isSimpleValueType. Also used byObjectUtils#nullSafeConciseToString.Check if the given type represents a common "simple" value type: primitive or primitive wrapper,
Enum,Stringor otherCharSequence,Number,Date,Temporal,ZoneId,TimeZone,File,Path,URI,URL,InetAddress,Charset,Currency,Locale,UUID,Pattern, orClass.Voidandvoidare 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
toStringoutput - Since:
- 6.1
-
isAssignable
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:
trueifrhsTypeis assignable tolhsType- See Also:
-
TypeUtils#isAssignable(java.lang.reflect.Type, java.lang.reflect.Type)
-