T
- The class type of the wrapped class.@Bean(properties="innerClass,classCategory,elementType,keyType,valueType,notABeanReason,initException,beanMeta") public final class ClassMeta<T> extends Object implements Type
Class
object that provides cached information about that class.
Instances of this class can be created through the BeanContext.getClassMeta(Class)
method.
The BeanContext
class will cache and reuse instances of this class except for the following class types:
This class is tied to the BeanContext
class because it's that class that makes the determination of what is
a bean.
Modifier and Type | Method and Description |
---|---|
boolean |
canCreateNewBean(Object outer)
Returns
|
boolean |
canCreateNewInstance()
Returns
|
boolean |
canCreateNewInstance(Object outer)
Returns
|
boolean |
canCreateNewInstanceFromString(Object outer)
Returns
newInstanceFromString(Object, String) method. |
boolean |
equals(Object t)
Checks to see if the specified class type is the same as this one.
|
protected static <T> Constructor<? extends T> |
findNoArgConstructor(Class<?> c,
Visibility v)
Locates the no-arg constructor for the specified class.
|
<A extends Annotation> |
getAnnotation(Class<A> a)
Shortcut for calling
|
ClassMeta<?> |
getArg(int index)
Returns the argument metadata at the specified index if this is an args metadata object.
|
ClassMeta<?>[] |
getArgs()
Returns the argument types of this meta.
|
BeanContext |
getBeanContext()
Returns the
BeanContext that created this object. |
BeanMeta<T> |
getBeanMeta()
Returns the
BeanMeta associated with this class. |
BeanRegistry |
getBeanRegistry()
Returns the bean registry for this class.
|
String |
getBeanTypePropertyName()
Returns the type property name associated with this class and subclasses.
|
BuilderSwap<T,?> |
getBuilderSwap(BeanSession session)
Returns the builder swap associated with this class.
|
protected PojoSwap<?,?> |
getChildPojoSwapForSwap(Class<?> normalClass)
Returns the
PojoSwap where the specified class is the same/subclass of the normal class of one of the
child POJO swaps associated with this class. |
protected PojoSwap<?,?> |
getChildPojoSwapForUnswap(Class<?> swapClass)
Returns the
PojoSwap where the specified class is the same/subclass of the swap class of one of the child
POJO swaps associated with this class. |
org.apache.juneau.ClassMeta.ClassCategory |
getClassCategory()
Returns the category of this class.
|
ConstructorInfo |
getConstructor()
Returns the no-arg constructor for this class.
|
String |
getDictionaryName()
Returns the bean dictionary name associated with this class.
|
ClassMeta<?> |
getElementType()
For array and
Collection types, returns the class type of the components of the array or
Collection . |
T |
getExample(BeanSession session)
Returns the example of this class.
|
<M extends ClassMetaExtended> |
getExtendedMeta(Class<M> c)
Returns the language-specified extended metadata on this class.
|
<I> Mutater<I,T> |
getFromMutater(Class<I> c)
Returns the transform for this class for creating instances from other object types.
|
String |
getFullName()
Returns a readable name for this class (e.g.
|
ClassInfo |
getInfo()
Returns the
ClassInfo wrapper for the underlying class. |
Throwable |
getInitException()
Returns any exception that was throw in the
|
Class<T> |
getInnerClass()
Returns the
Class object that this class type wraps. |
Mutater<InputStream,T> |
getInputStreamMutater()
Returns the transform for this class for creating instances from an InputStream.
|
ClassMeta<?> |
getKeyType()
For
Map types, returns the class type of the keys of the Map . |
String |
getName()
Shortcut for calling
Class.getName() on the inner class of this metadata. |
Setter |
getNameProperty()
Returns the method or field annotated with
@NameProperty . |
String |
getNotABeanReason()
Returns the reason why this class is not a bean, or
|
Optional<?> |
getOptionalDefault()
If this is an
Optional , returns an empty optional. |
Setter |
getParentProperty()
Returns the method or field annotated with
@ParentProperty . |
PojoSwap<T,?> |
getPojoSwap(BeanSession session)
Returns the
PojoSwap associated with this class that's the best match for the specified session. |
T |
getPrimitiveDefault()
Returns the default value for primitives such as
|
InvocationHandler |
getProxyInvocationHandler()
Returns the interface proxy invocation handler for this class.
|
Map<String,Method> |
getPublicMethods()
All public methods on this class including static methods.
|
Mutater<Reader,T> |
getReaderMutater()
Returns the transform for this class for creating instances from a Reader.
|
ClassMeta<?> |
getSerializedClassMeta(BeanSession session)
Returns the serialized (swapped) form of this class if there is an
PojoSwap associated with it. |
String |
getSimpleName()
Shortcut for calling
Class.getSimpleName() on the inner class of this metadata. |
Mutater<String,T> |
getStringMutater()
Returns the transform for this class for creating instances from a String.
|
<O> Mutater<T,O> |
getToMutater(Class<O> c)
Returns the transform for this class for creating instances from other object types.
|
ClassMeta<?> |
getValueType()
For
Map types, returns the class type of the values of the Map . |
boolean |
hasAnnotation(Class<? extends Annotation> a)
Shortcut for calling
getInnerClass().getAnnotation(a) != . |
protected boolean |
hasChildPojoSwaps()
Returns
PojoSwap associated with it. |
int |
hashCode() |
boolean |
hasInputStreamMutater()
Returns
|
boolean |
hasMutaterFrom(Class<?> c)
Returns
|
boolean |
hasMutaterFrom(ClassMeta<?> c)
Returns
|
boolean |
hasMutaterTo(Class<?> c)
Returns
|
boolean |
hasMutaterTo(ClassMeta<?> c)
Returns
|
boolean |
hasReaderMutater()
Returns
|
boolean |
hasStringMutater()
Returns
|
boolean |
isAbstract()
Returns
|
boolean |
isArgs()
Returns
|
boolean |
isArray()
Returns
|
boolean |
isAssignableFrom(Class<?> c)
Returns
|
boolean |
isBean()
Returns
|
boolean |
isBeanMap()
Returns
BeanMap . |
boolean |
isBoolean()
Returns
Boolean . |
boolean |
isByteArray()
Returns
. |
boolean |
isCalendar()
Returns
Calendar . |
boolean |
isChar()
Returns
Character . |
boolean |
isCharSequence()
Returns
CharSequence . |
boolean |
isClass()
Returns
Class . |
boolean |
isCollection()
Returns
Collection . |
boolean |
isCollectionOrArray()
Returns
Collection or is an array. |
boolean |
isCollectionOrArrayOrOptional()
|
boolean |
isDate()
Returns
Date . |
boolean |
isDateOrCalendar()
|
boolean |
isDecimal()
|
boolean |
isDelegate()
Returns
Delegate , meaning it's a representation of some other
object. |
boolean |
isDouble()
|
boolean |
isEnum()
Returns
Enum . |
boolean |
isFloat()
|
boolean |
isInputStream()
Returns
InputStream . |
boolean |
isInstance(Object o)
Returns
|
boolean |
isInstanceOf(Class<?> c)
Returns
|
boolean |
isInteger()
|
boolean |
isList()
Returns
List . |
boolean |
isLong()
|
boolean |
isMap()
Returns
Map . |
boolean |
isMapOrBean()
Returns
Map or it's a bean. |
boolean |
isMemberClass()
Returns
|
boolean |
isMethod()
Returns
Method . |
boolean |
isNotObject()
Returns
Object . |
boolean |
isNullable()
Returns
|
boolean |
isNumber()
Returns
Number . |
boolean |
isObject()
Returns
Object . |
boolean |
isOptional()
Returns
Optional . |
boolean |
isPrimitive()
Returns
|
boolean |
isReader()
Returns
Reader . |
boolean |
isSet()
Returns
Set . |
boolean |
isShort()
|
boolean |
isString()
Returns
String . |
boolean |
isType(Class<?> c)
Returns
|
boolean |
isUri()
|
boolean |
isVoid()
|
T |
mutateFrom(Object o)
Transforms the specified object into an instance of this class.
|
<O> O |
mutateTo(Object o,
Class<O> c)
Transforms the specified object into an instance of this class.
|
<O> O |
mutateTo(Object o,
ClassMeta<O> c)
Transforms the specified object into an instance of this class.
|
T |
newInstance()
Create a new instance of the main class of this declared type.
|
T |
newInstance(Object outer)
Same as
newInstance() except for instantiating non-static member classes. |
T |
newInstanceFromString(Object outer,
String arg)
Create a new instance of the main class of this declared type from a
|
boolean |
same(ClassMeta<?> cm)
Similar to
equals(Object) except primitive and Object types that are similar are considered the same. |
String |
toString() |
String |
toString(boolean simple)
Same as
toString() except use simple class names. |
String |
toString(Object t)
Converts the specified object to a string.
|
protected StringBuilder |
toString(StringBuilder sb,
boolean simple)
Appends this object as a readable string to the specified string builder.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getTypeName
public ClassInfo getInfo()
ClassInfo
wrapper for the underlying class.ClassInfo
wrapper for the underlying class, never public String getBeanTypePropertyName()
If
public String getDictionaryName()
The lexical name is defined by @Bean(typeName)
.
public BeanRegistry getBeanRegistry()
This bean registry contains names specified in the @Bean(beanDictionary)
annotation
defined on the class, regardless of whether the class is an actual bean.
This allows interfaces to define subclasses with type names.
public org.apache.juneau.ClassMeta.ClassCategory getClassCategory()
public boolean isAssignableFrom(Class<?> c)
c
- The comparison class.public boolean isInstanceOf(Class<?> c)
c
- The comparison class.protected boolean hasChildPojoSwaps()
PojoSwap
associated 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.
PojoSwap
associated with it.protected PojoSwap<?,?> getChildPojoSwapForSwap(Class<?> normalClass)
PojoSwap
where the specified class is the same/subclass of the normal class of one of the
child POJO swaps associated with this class.normalClass
- The normal class being resolved.PojoSwap
or protected PojoSwap<?,?> getChildPojoSwapForUnswap(Class<?> swapClass)
PojoSwap
where the specified class is the same/subclass of the swap class of one of the child
POJO swaps associated with this class.swapClass
- The swap class being resolved.PojoSwap
or protected static <T> Constructor<? extends T> findNoArgConstructor(Class<?> c, Visibility v)
Constructor must match the visibility requirements specified by parameter 'v'.
If class is abstract, always returns
c
- The class from which to locate the no-arg constructor.v
- The minimum visibility.public Class<T> getInnerClass()
Class
object that this class type wraps.@BeanIgnore public ClassMeta<?> getSerializedClassMeta(BeanSession session)
PojoSwap
associated with it.session
- The bean session.
@BeanIgnore public T getExample(BeanSession session)
session
- The bean session.
public ClassMeta<?> getElementType()
Collection
types, returns the class type of the components of the array or
Collection
.public ClassMeta<?> getKeyType()
Map
types, returns the class type of the keys of the Map
.public ClassMeta<?> getValueType()
Map
types, returns the class type of the values of the Map
.public boolean isDelegate()
Delegate
, meaning it's a representation of some other
object.Delegate
.public boolean isMap()
Map
.Map
.public boolean isMapOrBean()
Map
or it's a bean.Map
or it's a bean.public boolean isBeanMap()
BeanMap
.BeanMap
.public boolean isCollection()
Collection
.Collection
.public boolean isOptional()
Optional
.Optional
.public boolean isCollectionOrArray()
Collection
or is an array.Collection
or is an array.public boolean isCollectionOrArrayOrOptional()
Collection
or is an array or Optional
.public boolean isSet()
Set
.Set
.public boolean isList()
List
.List
.public boolean isByteArray()
byte []
.byte []
.public boolean isClass()
Class
.Class
.public boolean isMethod()
Method
.Method
.public boolean isEnum()
Enum
.Enum
.public boolean isArray()
public boolean isBean()
public boolean isObject()
Object
.Object
.public boolean isNotObject()
Object
.Object
.public boolean isNumber()
Number
.Number
.public boolean isType(Class<?> c)
c
- The class to test against.public boolean isBoolean()
Boolean
.Boolean
.public boolean isCharSequence()
CharSequence
.CharSequence
.public boolean isString()
String
.String
.public boolean isChar()
Character
.Character
.public boolean isPrimitive()
public boolean isDateOrCalendar()
public boolean isDate()
Date
.Date
.public boolean isCalendar()
Calendar
.Calendar
.public boolean isReader()
Reader
.Reader
.public boolean isInputStream()
InputStream
.InputStream
.public boolean isArgs()
public ClassMeta<?>[] getArgs()
public ClassMeta<?> getArg(int index)
index
- The argument index.BeanRuntimeException
- If this metadata object is not a list of arguments, or the index is out of range.public boolean isNullable()
Objects can be (
.
public boolean isAbstract()
public boolean isMemberClass()
public Map<String,Method> getPublicMethods()
Keys are method signatures.
public PojoSwap<T,?> getPojoSwap(BeanSession session)
PojoSwap
associated with this class that's the best match for the specified session.session
- The current bean session.
PojoSwap
associated with this class, or public BuilderSwap<T,?> getBuilderSwap(BeanSession session)
session
- The current bean session.public BeanMeta<T> getBeanMeta()
BeanMeta
associated with this class.BeanMeta
associated with this class, or public ConstructorInfo getConstructor()
public <M extends ClassMetaExtended> M getExtendedMeta(Class<M> c)
c
- The name of the metadata class to create.public InvocationHandler getProxyInvocationHandler()
public boolean canCreateNewInstance()
public boolean canCreateNewInstance(Object outer)
outer
- The outer class object for non-static member classes. Can be public boolean canCreateNewBean(Object outer)
outer
- The outer class object for non-static member classes. Can be public boolean canCreateNewInstanceFromString(Object outer)
newInstanceFromString(Object, String)
method.outer
- The outer class object for non-static member classes.
Can be public Setter getNameProperty()
@NameProperty
.@NameProperty
or public Setter getParentProperty()
@ParentProperty
.@ParentProperty
or public String getNotABeanReason()
public Throwable getInitException()
public BeanContext getBeanContext()
BeanContext
that created this object.public T getPrimitiveDefault()
public Optional<?> getOptionalDefault()
Optional
, returns an empty optional.
Note that if this is a nested optional, will recursively create empty optionals.
public String toString(Object t)
t
- The object to convert.public T newInstanceFromString(Object outer, String arg) throws ExecutableException
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);
outer
- The outer class object for non-static member classes. Can be arg
- The input argument value.ExecutableException
- Exception occurred on invoked constructor/method/field.public T newInstance() throws ExecutableException
ExecutableException
- Exception occurred on invoked constructor/method/field.public T newInstance(Object outer) throws ExecutableException
newInstance()
except for instantiating non-static member classes.outer
- The instance of the owning object of the member class instance.
Can be ExecutableException
- Exception occurred on invoked constructor/method/field.public boolean equals(Object t)
public boolean same(ClassMeta<?> cm)
equals(Object)
except primitive and Object types that are similar are considered the same.
(e.g. cm
- The class meta to compare to.public String toString(boolean simple)
toString()
except use simple class names.simple
- Print simple class names only (no package).protected StringBuilder toString(StringBuilder sb, boolean simple)
sb
- The string builder to append this object to.simple
- Print simple class names only (no package).public boolean isInstance(Object o)
This is a simple comparison on the base class itself and not on any generic parameters.
o
- The object to check.public String getFullName()
public String getName()
Class.getName()
on the inner class of this metadata.public String getSimpleName()
Class.getSimpleName()
on the inner class of this metadata.public boolean hasReaderMutater()
public Mutater<Reader,T> getReaderMutater()
public boolean hasInputStreamMutater()
public Mutater<InputStream,T> getInputStreamMutater()
public boolean hasStringMutater()
public Mutater<String,T> getStringMutater()
public boolean hasMutaterFrom(Class<?> c)
c
- The class type to convert from.public boolean hasMutaterFrom(ClassMeta<?> c)
c
- The class type to convert from.public boolean hasMutaterTo(Class<?> c)
c
- The class type to convert from.public boolean hasMutaterTo(ClassMeta<?> c)
c
- The class type to convert from.public T mutateFrom(Object o)
o
- The object to transform.public <O> O mutateTo(Object o, Class<O> c)
o
- The object to transform.c
- The classpublic <O> O mutateTo(Object o, ClassMeta<O> c)
o
- The object to transform.c
- The classpublic <I> Mutater<I,T> getFromMutater(Class<I> c)
c
- The transform-from class.public <O> Mutater<T,O> getToMutater(Class<O> c)
c
- The transform-from class.public boolean hasAnnotation(Class<? extends Annotation> a)
getInnerClass().getAnnotation(a) != null
.a
- The annotation to check for.public <A extends Annotation> A getAnnotation(Class<A> a)
a
- The annotation to retrieve.Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.