T
- the type for which to add supportpublic abstract class TypeSupport<T> extends Object
For a type to be usable by the library it needs to be defined:
Constructor and Description |
---|
TypeSupport(Class<T> type,
Class<? extends TypeSupport> typeSupportFamily)
Creates a new type support of the given type
|
Modifier and Type | Method and Description |
---|---|
static void |
addTypeSupport(TypeSupport<?> typeSupport)
Adds type support for the given class.
|
protected static <T> TypeSupport<T> |
findTypeSupportFor(Class<? extends TypeSupport> supportFamily,
Class<T> typeClass)
Calculates and caches the type support for a particular class, so that
introspection does not occur at every call.
|
protected Class<T> |
getType()
Defines on which class the support is defined.
|
protected Class<? extends TypeSupport> |
getTypeSupportFamily()
Defines which type of support is implementing, notification or time.
|
static boolean |
isTypeDirectlySupported(Class<? extends TypeSupport> typeSupportFamily,
Class<?> type)
Checks whether the type is supported on the same exact type.
|
static boolean |
isTypeSupported(Class<? extends TypeSupport> typeSupportFamily,
Class<?> type)
Checks whether the type is supported directly or through one of the
supertypes.
|
protected static <T extends TypeSupport<?>> |
typeSupportsFor(Class<T> supportFamily)
Returns all the type supports available for the given class.
|
public TypeSupport(Class<T> type, Class<? extends TypeSupport> typeSupportFamily)
type
- the type on which support is definedtypeSupportFamily
- the kind of support is being definedpublic static void addTypeSupport(TypeSupport<?> typeSupport)
typeSupport
- the support to addpublic static boolean isTypeSupported(Class<? extends TypeSupport> typeSupportFamily, Class<?> type)
type
- type to check support fortypeSupportFamily
- the family in which to look forRuntimeException
- if multiple conflicting support is foundpublic static boolean isTypeDirectlySupported(Class<? extends TypeSupport> typeSupportFamily, Class<?> type)
type
- type to check support fortypeSupportFamily
- the family in which to look forprotected static <T> TypeSupport<T> findTypeSupportFor(Class<? extends TypeSupport> supportFamily, Class<T> typeClass)
Find the supports for all supertypes. If multiple supports for different supertypes are found, and there isn't a most specific one (i.e. one that implements all the others) then an exception is thrown.
T
- the type to retrieve support forsupportFamily
- the support family for which to find supporttypeClass
- the class of the typeRuntimeException
- if multiple conflicting support is foundprotected static <T extends TypeSupport<?>> Collection<T> typeSupportsFor(Class<T> supportFamily)
T
- the kind of type supportsupportFamily
- the supported typeprotected Class<? extends TypeSupport> getTypeSupportFamily()
Copyright © 2010–2015. All rights reserved.