public class SingleTypeExtensionFactory<T,E> extends Object implements ExtensionFactory
ExtensionFactory
for a single extension type.Constructor and Description |
---|
SingleTypeExtensionFactory(Class<E> extensionType)
Constructs a
SingleTypeExtensionFactory for extensions of the given type. |
SingleTypeExtensionFactory(Class<E> extensionType,
Class<? extends E> extensionSubType)
Constructs a
SingleTypeExtensionFactory for extensions of the given sub-type which implement the given type. |
Modifier and Type | Method and Description |
---|---|
E |
getExtension(Object object,
Class<?> extensionType)
Gets an instance of an extension type for the specified object of type T.
|
protected E |
getExtensionImpl(T object,
Class<E> extensionType)
Creates an extension object for the given
object . |
Class<? extends E> |
getExtensionSubType() |
Class<E> |
getExtensionType() |
Class<?>[] |
getExtensionTypes() |
public SingleTypeExtensionFactory(Class<E> extensionType)
SingleTypeExtensionFactory
for extensions of the given type.
The extensionSubType
will be the same as the given type.extensionType
- The extension type.public SingleTypeExtensionFactory(Class<E> extensionType, Class<? extends E> extensionSubType)
SingleTypeExtensionFactory
for extensions of the given sub-type which implement the given type.extensionType
- The extension type. Must be assignable from
extensionSubType
.extensionSubType
- The specific extension sub-type.public final Class<? extends E> getExtensionSubType()
public final E getExtension(Object object, Class<?> extensionType)
extensionType
is assignable from the given extensionType
, the method
calls getExtensionImpl(Object, Class)
. Otherwise null
is returned.getExtension
in interface ExtensionFactory
object
- The object to be extended.extensionType
- The type of the requested extension.null
if the given object is not extensible by this factory or if an error occurs during the call to getExtensionImpl(Object, Class)
.protected E getExtensionImpl(T object, Class<E> extensionType) throws Throwable
object
.
The new extension object must be an instance of the extensionSubType
passed to the constructor.
Called if, and only if this factory's extensionType
is assignable from the given extensionType
.
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 given object
. Clients may subclass and
override this method in order to implement a more sophisticated instance creation.
object
- The object to be extended.extensionType
- The type of the requested extension.Throwable
- If an error occurs.public final Class<?>[] getExtensionTypes()
getExtensionTypes
in interface ExtensionFactory
extensionType
and optionally
the extensionSubType
supported by this factory.Copyright © 2014–2017 European Space Agency (ESA). All rights reserved.