Class ClassMeta<T>
- Type Parameters:
T- The class type of the wrapped class.
- All Implemented Interfaces:
Comparable<ClassInfo>,Type,Annotatable
Class object that provides cached information about that class.
Instances of this class can be created through the MarshallingContext.getClassMeta(Class) method.
The MarshallingContext class will cache and reuse instances of this class except for the following class types:
- Arrays
- Maps with non-Object key/values.
- Collections with non-Object key/values.
This class is tied to the MarshallingContext class because it's that class that makes the determination of what is
a bean.
-
Method Summary
Modifier and TypeMethodDescriptionbooleancanConvertFrom(Class<?> c) Returnstrue if this class can be instantiated from the specified input type.booleancanConvertTo(Class<?> c) Returnstrue if this class can be converted to the specified output type.booleancanCreateNewBean(Object outer) Returnstrue if this class can be instantiated as a bean.booleanReturnstrue if this class has a no-arg constructor or invocation handler.booleancanCreateNewInstance(Object outer) Returnstrue if this class has a no-arg constructor or invocation handler.booleanReturnstrue if this class can call thenewInstanceFromString(Object, String)method.booleanprotected ObjectSwap<?,?> protected ObjectSwap<?,?> findUnswap(Class<?> c) <A extends Annotation>
ClassMeta<T>forEachAnnotation(Class<A> type, Predicate<A> filter, Consumer<A> action) Performs an action on all matching annotations of the specified type defined on this class or parent classes/interfaces in parent-to-child order.ClassMeta<?>getArg(int index) Returns the argument metadata at the specified index if this is an args metadata object.getArgs()Returns the argument types of this meta.Returns the bean dictionary name associated with this class.Returns theBeanMetaassociated with this class.getBeanMeta(PropertyNamer propertyNamer) Same asgetBeanMeta()but derives property names using the suppliedPropertyNamerinstead of the one configured on the owning context.Returns the bean registry for this class.BuilderSwap<T,?> getBuilderSwap(MarshallingSession session) Returns the builder swap associated with this class.protected ObjectSwap<?,?> getChildObjectSwapForSwap(Class<?> normalClass) Returns theObjectSwapwhere the specified class is the same/subclass of the normal class of one of the child POJO swaps associated with this class.protected ObjectSwap<?,?> getChildObjectSwapForUnswap(Class<?> swapClass) Returns theObjectSwapwhere the specified class is the same/subclass of the swap class of one of the child POJO swaps associated with this class.ClassMeta<?>For array andCollectiontypes, returns the class type of the components of the array orCollection.getExample(MarshallingSession session, JsonParserSession jpSession) Returns the example of this class.getImplClassConstructor(Visibility conVis) Returns the no-arg constructor for this class based on theMarshalled.implClass()value.ClassMeta<?>ForMaptypes, returns the class type of the keys of theMap.Returns theMarshallingContextthat created this object.Returns the method or field annotated with@NameProperty.Returns the reason why this class is not a bean, ornull if it is a bean.Optional<?>If this is anOptional, returns an empty optional.Type[]Returns the type parameters for this class as aTypearray suitable for passing toConverter.to(Object, Type, Type...).Returns the method or field annotated with@ParentProperty.<T2> Optional<T2>getProperty(String name, Function<ClassMeta<?>, T2> function) Returns a lazily-computed, cached property value for thisClassMetainstance.Returns the interface proxy invocation handler for this class.ClassMeta<?>getSerializedClassMeta(MarshallingSession session) Returns the serialized (swapped) form of this class if there is anObjectSwapassociated with it.ObjectSwap<T,?> getSwap(MarshallingSession session) Returns theObjectSwapassociated with this class that's the best match for the specified session.ClassMeta<?>ForMaptypes, returns the class type of the values of theMap.protected booleanReturnstrue if this class or any child classes has aObjectSwapassociated with it.inthashCode()booleanReturnstrue if this class has a transform associated with it that allows it to be created from an InputStream.booleanhasMutaterFrom(Class<?> c) Returnstrue if this class can be instantiated from the specified type via an explicit conversion.booleanhasMutaterFrom(ClassMeta<?> c) Returnstrue if this class can be instantiated from the specified type via an explicit conversion.booleanhasMutaterTo(Class<?> c) Returnstrue if this class can be transformed to the specified type via an explicit conversion.booleanhasMutaterTo(ClassMeta<?> c) Returnstrue if this class can be transformed to the specified type via an explicit conversion.booleanReturnstrue if this class has a transform associated with it that allows it to be created from a Reader.booleanReturnstrue if this class has a transform associated with it that allows it to be created from a String.booleanisArgs()Returnstrue if this metadata represents an array of argument types.booleanisBean()Returnstrue if this class is a bean.booleanReturnstrue if this class is a subclass ofBeanMap.booleanReturnstrue if this class is aBoolean.booleanReturnstrue if this class is.byte []booleanReturnstrue if this class is aCalendar.booleanisChar()Returnstrue if this class is aCharacter.booleanReturnstrue if this class is a subclass ofCharSequence.booleanReturnstrue if this class is a subclass ofCollection.booleanbooleanisDate()Returnstrue if this class is aDate.booleanbooleanbooleanbooleanReturnstrue if this class implementsDelegate, meaning it's a representation of some other object.booleanisDouble()booleanReturnstrue if this class is aDuration.booleanisFloat()booleanReturnstrue if this class is anInputStream.booleanbooleanbooleanbooleanisList()Returnstrue if this class extends fromList.booleanisLong()booleanisMap()Returnstrue if this class is a subclass ofMap.booleanReturnstrue if this class is a subclass ofMapor it's a bean.booleanisMethod()Returnstrue if this class isMethod.booleanReturnstrue if instance of this object can benull .booleanisNumber()Returnstrue if this class is a subclass ofNumber.booleanReturnstrue if this class isOptionalor one of its primitive cousins (OptionalInt/OptionalLong/OptionalDouble).booleanisPeriod()Returnstrue if this class is aPeriod.booleanReturnstrue if this is one of the primitiveOptionalcousins (OptionalInt,OptionalLong, orOptionalDouble).booleanisReader()Returnstrue if this class is aReader.booleanisSet()Returnstrue if this class extends fromSet.booleanisShort()booleanisStream()booleanbooleanisString()Returnstrue if this class is aString.booleanReturnstrue if this class is aTemporal.booleanisUri()mutateFrom(Object o) Converts the specified object into an instance of this class.static <O> OConverts the specified object to the specified output type.static <O> OConverts the specified object to the type represented by this class meta.Create a new instance of the main class of this declared type.newInstance(Object outer) Same asnewInstance()except for instantiating non-static member classes.newInstanceFromString(Object outer, String arg) Create a new instance of the main class of this declared type from aString input.booleanSimilar toequals(Object)except primitive and Object types that are similar are considered the same.toString()Returns a detailed string representation of this class.toString(boolean simple) Same astoString()except use simple class names.Converts the specified object to a string.protected StringBuildertoString(StringBuilder sb, boolean simple) Appends this object as a readable string to the specified string builder.Methods inherited from class org.apache.juneau.commons.reflect.ClassInfoTyped
getPrimitiveDefault, innerMethods inherited from class org.apache.juneau.commons.reflect.ClassInfo
appendNameFormatted, arrayType, asSubclass, canAcceptArg, cast, compareTo, componentType, descriptorString, findGetter, findSetter, getAllFields, getAllMethods, getAllMethodsTopDown, getAllParents, getAnnotatableType, getAnnotatedInterfaces, getAnnotatedSuperclass, getAnnotations, getAnnotations, getClassLoader, getComponentType, getDeclaredAnnotations, getDeclaredConstructor, getDeclaredConstructors, getDeclaredField, getDeclaredFields, getDeclaredFieldsInDeclarationOrder, getDeclaredInterfaces, getDeclaredMemberClasses, getDeclaredMethod, getDeclaredMethods, getDeclaringClass, getDimensions, getEnclosingClass, getEnclosingConstructor, getEnclosingMethod, getGenericInterfaces, getGenericSuperclass, getInterfaces, getLabel, getMemberClasses, getMethod, getModule, getName, getNameCanonical, getNameFormatted, getNameFull, getNameReadable, getNames, getNameShort, getNameSimple, getNestHost, getNestMembers, getNoArgConstructor, getPackage, getPackageAnnotation, getParameterType, getParents, getParentsAndInterfaces, getPermittedSubclasses, getPrimitiveForWrapper, getPrimitiveWrapper, getProtectionDomain, getPublicConstructor, getPublicConstructors, getPublicField, getPublicFields, getPublicMethod, getPublicMethods, getRecordComponents, getRepeatedAnnotationMethod, getResource, getResourceAsStream, getSigners, getSuperclass, getTypeParameters, getWrapperIfPrimitive, hasAnnotation, hasPackage, hasPrimitiveWrapper, inject, inject, innerType, is, is, is, isAnnotation, isAnonymousClass, isAny, isAny, isAny, isAny, isAny, isArray, isAssignableFrom, isAssignableFrom, isAssignableFrom, isAssignableTo, isAssignableTo, isAssignableTo, isAssignableToAny, isChildOf, isChildOf, isChildOf, isClass, isCollectionOrArray, isDeprecated, isEnum, isInjectCollectionType, isInstance, isLocalClass, isMemberClass, isNestmateOf, isNonStaticMemberClass, isNotDeprecated, isNotLocalClass, isNotMemberClass, isNotNonStaticMemberClass, isNotPrimitive, isNotVoid, isObject, isParentOf, isParentOf, isParentOf, isParentOfLenient, isParentOfLenient, isParentOfLenient, isPrimitive, isRecord, isRepeatedAnnotation, isRuntimeException, isSealed, isStrictChildOf, isSynthetic, isVisible, isVoid, of, of, of, of, ofProxy, unwrapMethods inherited from class org.apache.juneau.commons.reflect.ElementInfo
ai, getModifiers, isAbstract, isAll, isAny, isFinal, isInterface, isNative, isNotAbstract, isNotFinal, isNotInterface, isNotNative, isNotPrivate, isNotProtected, isNotPublic, isNotStatic, isNotSynchronized, isNotTransient, isNotVolatile, isPrivate, isProtected, isPublic, isStatic, isSynchronized, isTransient, isVolatileMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.reflect.Type
getTypeName
-
Method Details
-
findSwap
-
findUnswap
-
canCreateNewBean
Returnstrue if this class can be instantiated as a bean. Returnsfalse if this is a non-static member class and the outer object does not match the class type of the defining class.- Parameters:
outer- The outer class object for non-static member classes. Can benull for non-member or static classes.- Returns:
true if a new instance of this bean can be created within the context of the specified outer object.
-
canCreateNewInstance
Returnstrue if this class has a no-arg constructor or invocation handler.- Specified by:
canCreateNewInstancein classBeanInfo<T>- Returns:
true if a new instance of this class can be constructed.
-
canCreateNewInstance
Returnstrue if this class has a no-arg constructor or invocation handler. Returnsfalse if this is a non-static member class and the outer object does not match the class type of the defining class.- Specified by:
canCreateNewInstancein classBeanInfo<T>- Parameters:
outer- The outer class object for non-static member classes. Can benull for non-member or static classes.- Returns:
true if a new instance of this class can be created within the context of the specified outer object.
-
canCreateNewInstanceFromString
Returnstrue if this class can call thenewInstanceFromString(Object, String)method.- Parameters:
outer- The outer class object for non-static member classes. Can benull for non-member or static classes.- Returns:
true if this class has a no-arg constructor or invocation handler.
-
equals
-
hashCode
-
forEachAnnotation
public <A extends Annotation> ClassMeta<T> forEachAnnotation(Class<A> type, Predicate<A> filter, Consumer<A> action) Performs an action on all matching annotations of the specified type defined on this class or parent classes/interfaces in parent-to-child order.- Type Parameters:
A- The annotation type to look for.- Parameters:
type- The annotation to search for.filter- A predicate to apply to the entries to determine if action should be performed. Can benull (if null, all entries are accepted).action- An action to perform on the entry.- Returns:
- This object.
-
getArg
Returns the argument metadata at the specified index if this is an args metadata object.- Parameters:
index- The argument index.- Returns:
- The argument metadata. Never
null . - Throws:
BeanRuntimeException- If this metadata object is not a list of arguments, or the index is out of range.
-
getArgs
Returns the argument types of this meta.- Returns:
- The argument types of this meta, or
null if this isn't an array of argument types.
-
getMarshallingContext
Returns theMarshallingContextthat created this object.Covariantly overrides
BeanInfo.getMarshallingContext()to narrow the return type fromObject(commons SPI) back toMarshallingContext(marshalling-side concrete type).- Specified by:
getMarshallingContextin classBeanInfo<T>- Returns:
- The bean context, or
null if this is an arguments-array metadata object (seeisArgs()).
-
getBeanConfigContext
Returns theBeanConfigContextsnapshot carried by theMarshallingContextthat built thisClassMeta.Satisfies the
BeanInfo.getBeanConfigContext()commons SPI contract.- Specified by:
getBeanConfigContextin classBeanInfo<T>- Returns:
- The bean-modeling configuration of the marshalling context. Never
null .
-
getBeanMeta
Returns theBeanMetaassociated with this class.- Returns:
- The
BeanMetaassociated with this class, ornull if there is no bean meta associated with this class.
-
getBeanMeta
Same asgetBeanMeta()but derives property names using the suppliedPropertyNamerinstead of the one configured on the owning context.Unlike
getBeanMeta(), the returnedBeanMetais built fresh on each call and is not cached — the shared,Class-keyed defaultBeanMeta(which uses the context's default namer) is left untouched. This keeps the cache safe when callers request an alternate property-naming strategy (e.g.MarshallingSession#toBeanMap(Object, PropertyNamer)).- Parameters:
propertyNamer- The property namer to use for deriving property names. Must not benull .- Returns:
- A newly-built
BeanMetawhose property names reflect the supplied namer, ornull if there is no bean meta associated with this class.
-
getBeanRegistry
Returns the bean registry for this class.This bean registry contains names specified in the
@Marshalled(dictionary)annotation defined on the class, regardless of whether the class is an actual bean. This allows interfaces to define subclasses with type names.This is a shortcut for calling getBeanMeta().getBeanRegistry().
- Returns:
- The bean registry for this class, or
null if no bean registry is associated with it.
-
getBuilderSwap
Returns the builder swap associated with this class.- Parameters:
session- The current bean session (retained for API compatibility).- Returns:
- The builder swap associated with this class, or
null if it doesn't exist.
-
getBeanDictionaryName
Returns the bean dictionary name associated with this class.The lexical name is defined by
@Marshalled(typeName).- Returns:
- The type name associated with this bean class, or
null if there is no type name defined or this isn't a bean.
-
getElementType
For array andCollectiontypes, returns the class type of the components of the array orCollection.- Specified by:
getElementTypein classBeanInfo<T>- Returns:
- The element class type, or
null if this class is not an array or Collection.
-
getExample
Returns the example of this class.- Parameters:
session- The bean session.
Required because the example method may take it in as a parameter.jpSession- The JSON parser for parsing examples into POJOs.- Returns:
- An example instance of this class, or
null if no example is defined or one could not be created.
-
canConvertFrom
Returnstrue if this class can be instantiated from the specified input type.- Parameters:
c- The input class type.- Returns:
true if a conversion exists.
-
getImplClassConstructor
Returns the no-arg constructor for this class based on theMarshalled.implClass()value.- Parameters:
conVis- The constructor visibility.- Returns:
- The no-arg constructor for this class, or
null if it does not exist.
-
getKeyType
ForMaptypes, returns the class type of the keys of theMap.- Specified by:
getKeyTypein classBeanInfo<T>- Returns:
- The key class type, or
null if this class is not a Map.
-
getNameProperty
Returns the method or field annotated with@NameProperty.- Returns:
- The method or field annotated with
@NamePropertyornull if method does not exist.
-
getNotABeanReason
Returns the reason why this class is not a bean, ornull if it is a bean.- Returns:
- The reason why this class is not a bean, or
null if it is a bean.
-
getOptionalDefault
If this is anOptional, returns an empty optional.Note that if this is a nested optional, will recursively create empty optionals.
- Specified by:
getOptionalDefaultin classBeanInfo<T>- Returns:
- An empty optional, or
null if this isn't an optional.
-
isPrimitiveOptional
Returnstrue if this is one of the primitiveOptionalcousins (OptionalInt,OptionalLong, orOptionalDouble).These types carry no generic element type but are treated as first-class optional types by the marshallers (mirroring the
Optionalcontract — empty ≡ null/absent, present unwraps to the primitive number). SeegetElementType()which synthesizes the matching boxed element type.- Returns:
true if this isOptionalInt/OptionalLong/OptionalDouble.
-
isOptional
Returnstrue if this class isOptionalor one of its primitive cousins (OptionalInt/OptionalLong/OptionalDouble).Overrides
ClassInfo.isOptional()so the marshalling layer treats the three primitive optional types as first-class optionals (synthetic boxed element type, empty-as-null contract) without registering swaps for them.- Overrides:
isOptionalin classClassInfo- Returns:
true if this is an optional-like type.
-
getParentProperty
Returns the method or field annotated with@ParentProperty.- Returns:
- The method or field annotated with
@ParentPropertyornull if method does not exist.
-
getProperty
Returns a lazily-computed, cached property value for thisClassMetainstance.This method provides a memoization mechanism for expensive computations. The property value is computed on the first call using the provided function, then cached for subsequent calls with the same property name.
The function is only invoked once per property name per
ClassMetainstance. Subsequent calls with the same name will return the cached value without re-invoking the function.Thread Safety:
This method is thread-safe. If multiple threads call this method simultaneously with the same property name, the function may be invoked multiple times, but only one result will be cached and returned.
Usage:
// Compute and cache an expensive property Optional<String>computedValue = classMeta.getProperty ("expensiveProperty" , cm -> {// Expensive computation that only runs once return performExpensiveComputation(cm); });// Subsequent calls return cached value Optional<String>cached = classMeta.getProperty ("expensiveProperty" , cm -> {// This function is NOT called again return performExpensiveComputation(cm); });- Type Parameters:
T2- The type of the property value.- Parameters:
name- The unique name identifying this property. Used as the cache key.function- The function that computes the property value. Receives thisClassMetainstance as input. Only invoked if the property hasn't been computed yet. Can returnnull .- Returns:
- An
Optionalcontaining the property value if the function returned a non-null value, otherwise an emptyOptional. Nevernull .
-
getProxyInvocationHandler
Returns the interface proxy invocation handler for this class.- Returns:
- The interface proxy invocation handler, or
null if it does not exist.
-
getSerializedClassMeta
Returns the serialized (swapped) form of this class if there is anObjectSwapassociated with it.- Parameters:
session- The bean session.
Required because the swap used may depend on the media type being serialized or parsed.- Returns:
- The serialized class type, or this object if no swap is associated with the class.
-
getSwap
Returns theObjectSwapassociated with this class that's the best match for the specified session.- Parameters:
session- The current bean session.
If multiple swaps are associated with a class, only the first one with a matching media type will be returned.- Returns:
- The
ObjectSwapassociated with this class, ornull if there are no POJO swaps associated with this class.
-
canConvertTo
Returnstrue if this class can be converted to the specified output type.- Parameters:
c- The output class type.- Returns:
true if a conversion exists.
-
getValueType
ForMaptypes, returns the class type of the values of theMap.- Specified by:
getValueTypein classBeanInfo<T>- Returns:
- The value class type, or
null if this class is not a Map.
-
getParameters
Returns the type parameters for this class as aTypearray suitable for passing toConverter.to(Object, Type, Type...).The returned array depends on the kind of type:
Maptypes:[keyType, valueType]CollectionandOptionaltypes:[elementType, elementType.getParameters()...]— the element raw class followed by the element's own parameters, recursively flattened by one level.- All other types: empty array.
Examples:
ClassMeta<Optional<Integer>> →[Integer] ClassMeta<List<Integer>> →[Integer] ClassMeta<Map<String,Integer>> →[String, Integer] ClassMeta<List<Map<String,Integer>>> →[Map, String, Integer]
- Returns:
- The type parameters as a
Typearray, nevernull .
-
hasInputStreamMutater
Returnstrue if this class has a transform associated with it that allows it to be created from an InputStream.Only returns
true for types that can be explicitly constructed from anInputStream(e.g. via a public constructor or static factory). Excludes assignable supertypes and the generictoString()fallback.- Returns:
true if this class has a transform associated with it that allows it to be created from an InputStream.
-
hasMutaterFrom
Returnstrue if this class can be instantiated from the specified type via an explicit conversion.Same-type conversions (identity) always return
true . Strict supertype relationships (where this class is already a supertype of the source) returnfalse — those are assignability, not explicit transforms.- Parameters:
c- The class type to convert from. Must not benull .- Returns:
true if an explicit conversion fromcto this type exists.
-
hasMutaterFrom
Returnstrue if this class can be instantiated from the specified type via an explicit conversion.- Parameters:
c- The class type to convert from. Must not benull .- Returns:
true if an explicit conversion fromcto this type exists.
-
hasMutaterTo
Returnstrue if this class can be transformed to the specified type via an explicit conversion.Same-type conversions (identity) always return
true . Cases where the target is already a strict supertype of this class returnfalse — those are assignability, not explicit transforms.- Parameters:
c- The class type to convert to. Must not benull .- Returns:
true if an explicit conversion from this type tocexists.
-
hasMutaterTo
Returnstrue if this class can be transformed to the specified type via an explicit conversion.- Parameters:
c- The class type to convert to. Must not benull .- Returns:
true if an explicit conversion from this type tocexists.
-
hasReaderMutater
Returnstrue if this class has a transform associated with it that allows it to be created from a Reader.Only returns
true for types that can be explicitly constructed from aReader(e.g. via a public constructor or static factory). Excludes assignable supertypes and the generictoString()fallback.- Returns:
true if this class has a transform associated with it that allows it to be created from a Reader.
-
hasStringMutater
Returnstrue if this class has a transform associated with it that allows it to be created from a String.Delegates to
hasMutaterFrom(Class)withStringas the source type, which applies the same exclusions: supertypes ofString(e.g.Object), arrays, andCollection/Maptargets are excluded because those are handled by parsers orMarshallingSession, not explicit string transforms.- Returns:
true if this class has a transform associated with it that allows it to be created from a String.
-
isArgs
Returnstrue if this metadata represents an array of argument types.- Returns:
true if this metadata represents an array of argument types.
-
isBean
Returnstrue if this class is a bean. -
isBeanMap
Returnstrue if this class is a subclass ofBeanMap.- Returns:
true if this class is a subclass ofBeanMap.
-
isBoolean
Returnstrue if this class is aBoolean. -
isByteArray
Returnstrue if this class is.byte []- Returns:
true if this class is.byte []
-
isCalendar
Returnstrue if this class is aCalendar.- Returns:
true if this class is aCalendar.
-
isChar
Returnstrue if this class is aCharacter.- Returns:
true if this class is aCharacter.
-
isCharSequence
Returnstrue if this class is a subclass ofCharSequence.- Overrides:
isCharSequencein classClassInfo- Returns:
true if this class is a subclass ofCharSequence.
-
isCollection
Returnstrue if this class is a subclass ofCollection.- Overrides:
isCollectionin classClassInfo- Returns:
true if this class is a subclass ofCollection.
-
isCollectionOrArrayOrOptional
- Returns:
true if this class is a subclass ofCollectionor is an array orOptional.
-
isDate
Returnstrue if this class is aDate.- Returns:
true if this class is aDate.
-
isDateOrCalendar
- Overrides:
isDateOrCalendarin classClassInfo- Returns:
true if this class is aDateorCalendar.
-
isDateOrCalendarOrTemporal
-
isDecimal
-
isDelegate
Returnstrue if this class implementsDelegate, meaning it's a representation of some other object.- Returns:
true if this class implementsDelegate.
-
isDouble
-
isFloat
- Returns:
true if this class is eitherFloatorfloat .
-
isInputStream
Returnstrue if this class is anInputStream.- Returns:
true if this class is anInputStream.
-
isInteger
- Returns:
true if this class is eitherIntegerorint .
-
isIterable
- Returns:
true if this class implementsIterablebut is not aCollection.- Since:
- 9.2.1
-
isIterator
- Returns:
true if this class implementsIteratororEnumeration.- Since:
- 9.2.1
-
isStreamable
Returnstrue if this class is anIterator,Iterable(non-Collection), orBaseStream.These types represent lazily-evaluated sequences that can be serialized as arrays.
- Returns:
true if this class is a streamable type.- Since:
- 9.2.1
-
isList
Returnstrue if this class extends fromList.- Returns:
true if this class extends fromList.
-
isLong
-
isMap
Returnstrue if this class is a subclass ofMap. -
isMapOrBean
Returnstrue if this class is a subclass ofMapor it's a bean.- Returns:
true if this class is a subclass ofMapor it's a bean.
-
isMethod
Returnstrue if this class isMethod.- Returns:
true if this class isMethod.
-
isNullable
Returnstrue if instance of this object can benull .Objects can be
null , but primitives cannot, except for chars which can be represented by(.char )0- Returns:
true if instance of this class can be null.
-
isNumber
Returnstrue if this class is a subclass ofNumber. -
isReader
Returnstrue if this class is aReader.- Returns:
true if this class is aReader.
-
isSet
Returnstrue if this class extends fromSet.- Returns:
true if this class extends fromSet.
-
isShort
- Returns:
true if this class is eitherShortorshort .
-
isStream
- Returns:
true if this class is a subclass ofBaseStream.- Since:
- 9.2.1
-
isString
Returnstrue if this class is aString.- Returns:
true if this class is aString.
-
isTemporal
Returnstrue if this class is aTemporal.- Overrides:
isTemporalin classClassInfo- Returns:
true if this class is aTemporal.
-
isDuration
Returnstrue if this class is aDuration.- Returns:
true if this class is aDuration.
-
isPeriod
Returnstrue if this class is aPeriod.- Returns:
true if this class is aPeriod.
-
isUri
-
mutateFrom
Converts the specified object into an instance of this class.- Parameters:
o- The object to convert.- Returns:
- The converted object, or
null if no conversion is available.
-
mutateTo
Converts the specified object to the specified output type.- Type Parameters:
O- The output class.- Parameters:
o- The object to convert.c- The target class.- Returns:
- The converted object, or
null if no conversion is available.
-
mutateTo
Converts the specified object to the type represented by this class meta.- Type Parameters:
O- The output class.- Parameters:
o- The object to convert.c- The target class meta. Must not benull .- Returns:
- The converted object, or
null if no conversion is available.
-
newInstance
Create a new instance of the main class of this declared type.- Specified by:
newInstancein classBeanInfo<T>- Returns:
- A new instance of the object, or
null if there is no no-arg constructor on the object. - Throws:
ExecutableException- Exception occurred on invoked constructor/method/field.
-
newInstance
Same asnewInstance()except for instantiating non-static member classes.- Parameters:
outer- The instance of the owning object of the member class instance. Can benull if instantiating a non-member or static class.- Returns:
- A new instance of the object, or
null if there is no no-arg constructor on the object. - Throws:
ExecutableException- Exception occurred on invoked constructor/method/field.
-
newInstanceFromString
Create a new instance of the main class of this declared type from aString input.In order to use this method, the class must have one of the following methods:
public static T valueOf(String in);public static T fromString(String in);public T(String in);
- Parameters:
outer- The outer class object for non-static member classes. Can benull for non-member or static classes.arg- The input argument value.- Returns:
- A new instance of the object, or
null if there is no string constructor on the object. - Throws:
ExecutableException- Exception occurred on invoked constructor/method/field.
-
same
Similar toequals(Object)except primitive and Object types that are similar are considered the same. (e.g.boolean ==Boolean ).- Parameters:
cm- The class meta to compare to. Can benull , in which case this method returnsfalse .- Returns:
true if the specified class-meta is equivalent to this one.
-
toString
Description copied from class:ClassInfoReturns a detailed string representation of this class.The returned string includes:
- Modifiers (public, private, protected, static, final, abstract, etc.)
- Class type (class, interface, enum, annotation, or record)
- Fully qualified class name
- Generic type parameters with bounds (if any)
Examples:
// Regular class ClassInfo.of (String.class ).toString();// Returns: "public final class java.lang.String" // Interface ClassInfo.of (List.class ).toString();// Returns: "public interface java.util.List" // Generic class ClassInfo.of (ArrayList.class ).toString();// Returns: "public class java.util.ArrayList<E>" // Generic class with bounds ClassInfoci = ClassInfo.of (Comparable.class );ci .toString();// Returns: "public interface java.lang.Comparable<T>" // Enum ClassInfo.of (Month.class ).toString();// Returns: "public enum java.time.Month" // Record ClassInforecord = ClassInfo.of (MyRecord.class );record .toString();// Returns: "public record org.example.MyRecord" Notes:
- For interfaces, the "abstract" modifier is omitted since it's implicit.
- For non-class types (e.g., TypeVariable, ParameterizedType), returns the result of
Type.toString(). - Type parameters include bounds when present (e.g., "<T extends Comparable<T>>").
Comparison with Other Methods:
ClassInfo.getNameSimple()- Returns simple class name without package (e.g., "String")ClassInfo.getNameShort()- Returns short name with outer classes (e.g., "MyClass$Inner")ClassInfo.getNameFull()- Returns fully qualified name with type parameters (e.g., "java.util.List<String>")
-
toString
Same astoString()except use simple class names.- Parameters:
simple- Print simple class names only (no package).- Returns:
- A new string.
-
toString
Converts the specified object to a string.- Parameters:
t- The object to convert. Can benull (returnsnull ).- Returns:
- The object converted to a string, or
null if the object was null.
-
getChildObjectSwapForSwap
Returns theObjectSwapwhere the specified class is the same/subclass of the normal class of one of the child POJO swaps associated with this class.- Parameters:
normalClass- The normal class being resolved.- Returns:
- The resolved
ObjectSwapornull if none were found.
-
getChildObjectSwapForUnswap
Returns theObjectSwapwhere the specified class is the same/subclass of the swap class of one of the child POJO swaps associated with this class.- Parameters:
swapClass- The swap class being resolved.- Returns:
- The resolved
ObjectSwapornull if none were found.
-
hasChildSwaps
Returnstrue if this class or any child classes has aObjectSwapassociated with it.Used when transforming bean properties to prevent having to look up transforms if we know for certain that no transforms are associated with a bean property.
- Returns:
true if this class or any child classes has aObjectSwapassociated with it.
-
toString
Appends this object as a readable string to the specified string builder.- Parameters:
sb- The string builder to append this object to. Must not benull .simple- Print simple class names only (no package).- Returns:
- The passed-in string builder.
-