Class Wrapper<T>
- java.lang.Object
-
- com.oracle.coherence.io.json.genson.Wrapper<T>
-
- All Implemented Interfaces:
AnnotatedElement
- Direct Known Subclasses:
BeanCreator,BeanViewConverter,ClassMetadataConverter,MissingClassConverter,RuntimeTypeConverter,SerializationSupportConverter
public abstract class Wrapper<T> extends Object implements AnnotatedElement
Wrapper class must be extended by decorated converters that wrap other converters. This allows to access merged class information of wrapped converter and the converter itself. So instead of doing myObject.getClass().isAnnotationPresent(..) you will do myObject.isAnnotationPresent(..), where myObject is an instance of Wrapper. For example to check if a converter (or any another encapsulated converter and so on) has annotation @HandleNull you will do it that way:Wrapper.toAnnotatedElement(converter).isAnnotationPresent(HandleNull.class);
In the future there may be other methods to access other kind of class information.- Author:
- Eugen Cepoi
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddecorate(T object)<A extends Annotation>
AgetAnnotation(Class<A> aClass)Annotation[]getAnnotations()Annotation[]getDeclaredAnnotations()booleanisAnnotationPresent(Class<? extends Annotation> annotationClass)static booleanisOfType(Object object, Class<?> clazz)static booleanisWrapped(Object object)static AnnotatedElementtoAnnotatedElement(Object object)This method acts as an adapter to AnnotatedElement, use it when you need to work on a converter annotations.Tunwrap()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.reflect.AnnotatedElement
getAnnotationsByType, getDeclaredAnnotation, getDeclaredAnnotationsByType
-
-
-
-
Field Detail
-
wrapped
protected volatile T wrapped
-
-
Constructor Detail
-
Wrapper
protected Wrapper()
-
Wrapper
protected Wrapper(T wrappedObject)
-
-
Method Detail
-
getAnnotations
public Annotation[] getAnnotations()
- Specified by:
getAnnotationsin interfaceAnnotatedElement
-
getAnnotation
public <A extends Annotation> A getAnnotation(Class<A> aClass)
- Specified by:
getAnnotationin interfaceAnnotatedElement
-
getDeclaredAnnotations
public Annotation[] getDeclaredAnnotations()
- Specified by:
getDeclaredAnnotationsin interfaceAnnotatedElement
-
isAnnotationPresent
public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
- Specified by:
isAnnotationPresentin interfaceAnnotatedElement
-
decorate
protected void decorate(T object)
-
unwrap
public T unwrap()
-
toAnnotatedElement
public static AnnotatedElement toAnnotatedElement(Object object)
This method acts as an adapter to AnnotatedElement, use it when you need to work on a converter annotations. In fact "object" argument will usually be of type converter. If this class is a wrapper than it will cast it to annotatedElement (as Wrapper implements AnnotatedElement). Otherwise we will return the class of this object.- Parameters:
object- may be an instance of converter for example- Returns:
- an annotatedElement that allows us to get annotations from this object and it's wrapped classes if it is a Wrapper.
-
isWrapped
public static boolean isWrapped(Object object)
-
-