org.epics.pvmanager
Class TypeSupport<T>

java.lang.Object
  extended by org.epics.pvmanager.TypeSupport<T>
Type Parameters:
T - the type for which to add support
Direct Known Subclasses:
NotificationSupport, TimeSupport

public abstract class TypeSupport<T>
extends java.lang.Object

Implements the mechanism for registering different types so that the library knows how to handle them.

For a type to be usable by the library it needs to be defined:

Author:
carcassi

Constructor Summary
TypeSupport(java.lang.Class<T> type, java.lang.Class<? extends TypeSupport> typeSupportFamily)
          Creates a new type support of the given type
 
Method Summary
static void addTypeSupport(TypeSupport<?> typeSupport)
          Adds type support for the given class.
protected static
<T> TypeSupport<T>
findTypeSupportFor(java.lang.Class<? extends TypeSupport> supportFamily, java.lang.Class<T> typeClass)
          Calculates and caches the type support for a particular class, so that introspection does not occur at every call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeSupport

public TypeSupport(java.lang.Class<T> type,
                   java.lang.Class<? extends TypeSupport> typeSupportFamily)
Creates a new type support of the given type

Parameters:
type - the type on which support is defined
typeSupportFamily - the kind of support is being defined
Method Detail

addTypeSupport

public static void addTypeSupport(TypeSupport<?> typeSupport)
Adds type support for the given class. The type support added will apply to the given class and all of its subclasses. Support of the same family cannot be added twice and will cause an exception. Support for the more specific subclass overrides support for the more abstract class. A class cannot have two types support in the same family coming from two different and unrelated interfaces.

Parameters:
typeSupport - the support to add

findTypeSupportFor

protected static <T> TypeSupport<T> findTypeSupportFor(java.lang.Class<? extends TypeSupport> supportFamily,
                                                       java.lang.Class<T> typeClass)
Calculates and caches the type support for a particular class, so that introspection does not occur at every call. First the supertypes are recursively

Type Parameters:
T - the type to retrieve support for
Parameters:
supportFamily - the support family for which to find support
typeClass - the class of the type
Returns:
the support for the type or null
Throws:
java.lang.RuntimeException - when no support could be identified


Copyright © 2011. All Rights Reserved.