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 |
canCreateNewInstanceFromNumber(Object outer)
Returns
newInstanceFromString(Object, String) method. |
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.
|
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.
|
Constructor<? extends T> |
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 . |
<M extends ClassMetaExtended> |
getExtendedMeta(Class<M> c)
Returns the language-specified extended metadata on this class.
|
Throwable |
getInitException()
Returns any exception that was throw in the
init() method. |
Class<T> |
getInnerClass()
Returns the
Class object that this class type wraps. |
ClassMeta<?> |
getKeyType()
For
Map types, returns the class type of the keys of the Map . |
Setter |
getNameProperty()
Returns the method or field annotated with
@NameProperty . |
Class<? extends Number> |
getNewInstanceFromNumberClass()
Returns the class type of the parameter of the numeric constructor.
|
String |
getNotABeanReason()
Returns the reason why this class is not a bean, or
|
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.
|
String |
getReadableName()
Returns a readable name for this class (e.g.
|
Map<String,Method> |
getRemoteableMethods()
All methods on this class annotated with
@Remotable , or all public methods if class is
annotated. |
ClassMeta<?> |
getSerializedClassMeta(BeanSession session)
Returns the serialized (swapped) form of this class if there is an
PojoSwap associated with it. |
ClassMeta<?> |
getValueType()
For
Map types, returns the class type of the values of the Map . |
protected boolean |
hasChildPojoSwaps()
Returns
PojoSwap associated with it. |
int |
hashCode() |
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 |
isChar()
Returns
Character . |
boolean |
isCharSequence()
Returns
CharSequence . |
boolean |
isClass()
Returns
Class . |
boolean |
isCollection()
Returns
Collection . |
boolean |
isCollectionOrArray()
Returns
Collection or is an array. |
boolean |
isDate()
|
boolean |
isDecimal()
|
boolean |
isDelegate()
Returns
Delegate , meaning it's a representation of some other
object. |
boolean |
isEnum()
Returns
Enum . |
boolean |
isInputStream()
Returns
InputStream . |
boolean |
isInstance(Object o)
Returns
|
boolean |
isInstanceOf(Class<?> c)
Returns
|
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 |
isPrimitive()
Returns
|
boolean |
isReader()
Returns
Reader . |
boolean |
isRemoteable()
Returns
@Remotable . |
boolean |
isString()
Returns
String . |
boolean |
isUri()
|
boolean |
isVoid()
|
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 |
newInstanceFromNumber(BeanSession session,
Object outer,
Number arg)
Create a new instance of the main class of this declared type from a
Number input. |
T |
newInstanceFromString(Object outer,
String arg)
Create a new instance of the main class of this declared type from a
String input. |
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. |
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 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.
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 isCollectionOrArray()
Collection
or is an array.Collection
or is an array.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 isBoolean()
Boolean
.Boolean
.public boolean isCharSequence()
CharSequence
.CharSequence
.public boolean isString()
String
.String
.public boolean isChar()
Character
.Character
.public boolean isPrimitive()
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 isRemoteable()
@Remotable
.public boolean isAbstract()
public boolean isMemberClass()
public Map<String,Method> getRemoteableMethods()
@Remotable
, or all public methods if class is
annotated.
Keys are method signatures.
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 Constructor<? extends T> 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 boolean canCreateNewInstanceFromNumber(Object outer)
newInstanceFromString(Object, String)
method.outer
- The outer class object for non-static member classes.
Can be public Class<? extends Number> getNewInstanceFromNumberClass()
public Setter getNameProperty()
@NameProperty
.@NameProperty
or public Setter getParentProperty()
@ParentProperty
.@ParentProperty
or public String getNotABeanReason()
public Throwable getInitException()
init()
method.public BeanContext getBeanContext()
BeanContext
that created this object.public T getPrimitiveDefault()
public T newInstanceFromString(Object outer, String arg) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException
String
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);
outer
- The outer class object for non-static member classes. Can be arg
- The input argument value.IllegalAccessException
- If the Constructor
object enforces Java language access control and the underlying constructor is
inaccessible.IllegalArgumentException
- If the parameter type on the method was invalid.InstantiationException
- If the class that declares the underlying constructor represents an abstract class, or does not have one of
the methods described above.InvocationTargetException
- If the underlying constructor throws an exception.public T newInstanceFromNumber(BeanSession session, Object outer, Number arg) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException
Number
input.
In order to use this method, the class must have one of the following methods:
public T(Number in);
session
- The current bean session.outer
- The outer class object for non-static member classes.
Can be arg
- The input argument value.IllegalAccessException
- If the Constructor
object enforces Java language access control and the underlying constructor is
inaccessible.IllegalArgumentException
- If the parameter type on the method was invalid.InstantiationException
- If the class that declares the underlying constructor represents an abstract class, or does not have one of
the methods described above.InvocationTargetException
- If the underlying constructor throws an exception.public T newInstance() throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
IllegalAccessException
- If the Constructor
object enforces Java language access control and the underlying constructor is
inaccessible.IllegalArgumentException
- If one of the following occurs:
InstantiationException
- If the class that declares the underlying constructor represents an abstract class.InvocationTargetException
- If the underlying constructor throws an exception.public T newInstance(Object outer) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
newInstance()
except for instantiating non-static member classes.outer
- The instance of the owning object of the member class instance.
Can be IllegalAccessException
- If the Constructor
object enforces Java language access control and the underlying constructor is
inaccessible.IllegalArgumentException
- If one of the following occurs:
InstantiationException
- If the class that declares the underlying constructor represents an abstract class.InvocationTargetException
- If the underlying constructor throws an exception.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. Boolean
).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 getReadableName()
Copyright © 2018 Apache. All rights reserved.