org.jboss.reflect.spi
Class AbstractTypeInfo

java.lang.Object
  extended by org.jboss.util.JBossObject
      extended by org.jboss.reflect.spi.AbstractTypeInfo
All Implemented Interfaces:
Serializable, Cloneable, TypeInfo, org.jboss.util.JBossInterface
Direct Known Subclasses:
DelegateClassInfo, PrimitiveInfo

public abstract class AbstractTypeInfo
extends org.jboss.util.JBossObject
implements TypeInfo

AbstractTypeInfo.

Version:
$Revision: 1.1 $
Author:
Adrian Brock
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jboss.util.JBossObject
hashCode, log, toString
 
Constructor Summary
AbstractTypeInfo()
           
 
Method Summary
<T> T
getAttachment(Class<T> expectedType)
          Get an attachment from the type, uses the expected type as both the name and to cast the resulting object.
 Object getAttachment(String name)
          Get an attachment from the type
 boolean isAnnotation()
          Whether this type is an annotation
 boolean isArray()
          Whether this type is an array
 boolean isCollection()
          Whether this type is a collection
 boolean isEnum()
          Whether this type is an enum
 boolean isMap()
          Whether this type is a map
 boolean isPrimitive()
          Whether this type is a primitive
 void setAttachment(String name, Object attachment)
          Set an attachment against the type.
 
Methods inherited from class org.jboss.util.JBossObject
cacheGetHashCode, cacheToString, clone, equals, flushJBossObjectCache, getClassShortName, getHashCode, hashCode, list, notEqual, toShortString, toShortString, toString, toString, toStringImplementation
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.reflect.spi.TypeInfo
convertValue, convertValue, convertValue, getArrayType, getName, getSimpleName, getType, getTypeInfoFactory, isAssignableFrom, isInstance, newArrayInstance
 

Constructor Detail

AbstractTypeInfo

public AbstractTypeInfo()
Method Detail

isArray

public boolean isArray()
Description copied from interface: TypeInfo
Whether this type is an array

Specified by:
isArray in interface TypeInfo
Returns:
true when an array

isCollection

public boolean isCollection()
Description copied from interface: TypeInfo
Whether this type is a collection

Specified by:
isCollection in interface TypeInfo
Returns:
true when a collection

isMap

public boolean isMap()
Description copied from interface: TypeInfo
Whether this type is a map

Specified by:
isMap in interface TypeInfo
Returns:
true when a map

isAnnotation

public boolean isAnnotation()
Description copied from interface: TypeInfo
Whether this type is an annotation

Specified by:
isAnnotation in interface TypeInfo
Returns:
true when an annotation

isEnum

public boolean isEnum()
Description copied from interface: TypeInfo
Whether this type is an enum

Specified by:
isEnum in interface TypeInfo
Returns:
true when an enum

isPrimitive

public boolean isPrimitive()
Description copied from interface: TypeInfo
Whether this type is a primitive

Specified by:
isPrimitive in interface TypeInfo
Returns:
true when a primtive

setAttachment

public void setAttachment(String name,
                          Object attachment)
Description copied from interface: TypeInfo
Set an attachment against the type. This is useful for caching information against a type.

If you add a future object, subsequent gets will wait for the result

WARNING: Be careful about what you put in here. Don't create references across classloaders, if you are not sure add a WeakReference to the information.

Specified by:
setAttachment in interface TypeInfo
Parameters:
name - the name
attachment - the attachment, pass null to remove an attachment

getAttachment

public <T> T getAttachment(Class<T> expectedType)
Description copied from interface: TypeInfo
Get an attachment from the type, uses the expected type as both the name and to cast the resulting object.

Specified by:
getAttachment in interface TypeInfo
Type Parameters:
T - the expected type
Parameters:
expectedType - the expected type
Returns:
the attachment

getAttachment

public Object getAttachment(String name)
Description copied from interface: TypeInfo
Get an attachment from the type

Specified by:
getAttachment in interface TypeInfo
Parameters:
name - the name
Returns:
the attachment


Copyright © 2010 JBoss, a division of Red Hat, Inc.. All Rights Reserved.