-
- All Known Implementing Classes:
AbstractExtendable
public interface Extendable<O>
- Author:
- Mathieu Bague
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <E extends Extension<O>>
voidaddExtension(Class<? super E> type, E extension)
Add en extension to this extendable object.<E extends Extension<O>>
EgetExtension(Class<? super E> type)
Get an extension based on its class type.<E extends Extension<O>>
EgetExtensionByName(String name)
Get an extension based on its name.<E extends Extension<O>>
Collection<E>getExtensions()
Get all extensions associated with this extendable object..default String
getImplementationName()
Returns a name that is used to find matchingExtensionAdderProvider
s when selecting implementations of extensions innewExtension(java.lang.Class<B>)
.default <E extends Extension<O>,B extends ExtensionAdder<O,E>>
BnewExtension(Class<B> type)
Returns an extensionAdder to build and add an extension for this extendable.<E extends Extension<O>>
booleanremoveExtension(Class<E> type)
Remove an extension based on its class type.
-
-
-
Method Detail
-
addExtension
<E extends Extension<O>> void addExtension(Class<? super E> type, E extension)
Add en extension to this extendable object.- Type Parameters:
E
- the extension type- Parameters:
type
- the extension class typeextension
- the extension
-
getExtension
<E extends Extension<O>> E getExtension(Class<? super E> type)
Get an extension based on its class type.- Type Parameters:
E
- the extension type- Parameters:
type
- the extension class type- Returns:
- the extension mapped to the class type or null if not found
-
getExtensionByName
<E extends Extension<O>> E getExtensionByName(String name)
Get an extension based on its name.- Parameters:
name
- the extension name- Returns:
- the extension mapped to the name or null if not found
-
removeExtension
<E extends Extension<O>> boolean removeExtension(Class<E> type)
Remove an extension based on its class type.- Type Parameters:
E
- the extension type- Parameters:
type
- the extension class type- Returns:
- true if the extension has been removed false if extension has not been found
-
getExtensions
<E extends Extension<O>> Collection<E> getExtensions()
Get all extensions associated with this extendable object..- Returns:
- all extensions associated to this extendable object.
-
getImplementationName
default String getImplementationName()
Returns a name that is used to find matchingExtensionAdderProvider
s when selecting implementations of extensions innewExtension(java.lang.Class<B>)
. This is meant to be overriden by extendables when multiple implementations exist.- Returns:
- the name
-
newExtension
default <E extends Extension<O>,B extends ExtensionAdder<O,E>> B newExtension(Class<B> type)
Returns an extensionAdder to build and add an extension for this extendable.The extension implementation is selected at runtime based on matching the
getImplementationName()
of this extendable to theExtensionAdderProvider.getImplementationName()
of a provider. Implementations are loaded with java'sServiceLoader
using the ExtensionAdderProvider interface.- Parameters:
type
- The interface of the ExtensionAdder- Returns:
- the adder
-
-