Package com.bc.ceres.core
Class SingleTypeExtensionFactory<T,E>
java.lang.Object
com.bc.ceres.core.SingleTypeExtensionFactory<T,E>
- All Implemented Interfaces:
ExtensionFactory
An implementation of a
ExtensionFactory for a single extension type.- Since:
- Ceres 0.9
- Version:
- $Revision$ $Date$
-
Constructor Summary
ConstructorsConstructorDescriptionSingleTypeExtensionFactory(Class<E> extensionType) Constructs aSingleTypeExtensionFactoryfor extensions of the given type.SingleTypeExtensionFactory(Class<E> extensionType, Class<? extends E> extensionSubType) Constructs aSingleTypeExtensionFactoryfor extensions of the given sub-type which implement the given type. -
Method Summary
Modifier and TypeMethodDescriptionfinal EgetExtension(Object object, Class<?> extensionType) Gets an instance of an extension type for the specified object of type T.protected EgetExtensionImpl(T object, Class<E> extensionType) Creates an extension object for the givenobject.final Class<?>[]
-
Constructor Details
-
SingleTypeExtensionFactory
Constructs aSingleTypeExtensionFactoryfor extensions of the given type. TheextensionSubTypewill be the same as the given type.- Parameters:
extensionType- The extension type.
-
SingleTypeExtensionFactory
Constructs aSingleTypeExtensionFactoryfor extensions of the given sub-type which implement the given type.- Parameters:
extensionType- The extension type. Must beassignable fromextensionSubType.extensionSubType- The specific extension sub-type.
-
-
Method Details
-
getExtensionType
- Returns:
- The extension type.
-
getExtensionSubType
- Returns:
- The specific extension sub-type.
-
getExtension
Gets an instance of an extension type for the specified object of type T. If this factory'sextensionTypeis assignable from the givenextensionType, the method callsgetExtensionImpl(Object, Class). Otherwisenullis returned.- Specified by:
getExtensionin interfaceExtensionFactory- Parameters:
object- The object to be extended.extensionType- The type of the requested extension.- Returns:
- The extension object, or
nullif the given object is not extensible by this factory or if an error occurs during the call togetExtensionImpl(Object, Class).
-
getExtensionImpl
Creates an extension object for the givenobject. The new extension object must be an instance of theextensionSubTypepassed to the constructor. Called if, and only if this factory'sextensionTypeis assignable from the givenextensionType.The default implementation returns a new instance of
extensionSubType, either created from its public no-arg constructor or its public 1-arg constructor which can take the givenobject. Clients may subclass and override this method in order to implement a more sophisticated instance creation.- Parameters:
object- The object to be extended.extensionType- The type of the requested extension.- Returns:
- The extension object.
- Throws:
Throwable- If an error occurs.
-
getExtensionTypes
- Specified by:
getExtensionTypesin interfaceExtensionFactory- Returns:
- The array containing the
extensionTypeand optionally theextensionSubTypesupported by this factory.
-