Interface Augmentable<T>
- Type Parameters:
T
- Base class which should implements this interface and is target for augmentation.
- All Known Subinterfaces:
EntryObject<T,
K>
- All Known Implementing Classes:
AbstractAugmentable
,AbstractEntryObject
,AugmentableCodecDataObject
public interface Augmentable<T>
Augmentable (extensible) object which could carry additional data defined by a third-party extension, without
introducing conflict between various extension.
This interface uses extended version of ExtensibleInterface pattern which also adds marker interface for
augmentations (extensions) - Augmentable
.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <A extends Augmentation<T>>
@Nullable Aaugmentation
(Class<A> augmentationType) Returns instance of augmentation, if present.default <A extends Augmentation<T>>
@NonNull AaugmentationOrElseThrow
(Class<A> augmentationType) Returns instance of augmentation, or throwsNoSuchElementException
.default <A extends Augmentation<T>,
X extends Throwable>
@NonNull AaugmentationOrElseThrow
(Class<A> augmentationType, Supplier<@NonNull X> exceptionSupplier) Returns instance of augmentation, or throwsNoSuchElementException
.@NonNull Map
<Class<? extends Augmentation<T>>, Augmentation<T>> Returns map of all augmentations.
-
Method Details
-
augmentation
Returns instance of augmentation, if present.- Type Parameters:
A
- Type capture for augmentation type- Parameters:
augmentationType
- Type of augmentation to be returned- Returns:
- instance of
A
, ornull
if the augmentationType is not present - Throws:
NullPointerException
- ifaugmentationType
isnull
-
augmentationOrElseThrow
Returns instance of augmentation, or throwsNoSuchElementException
.- Type Parameters:
A
- Type capture for augmentation type- Parameters:
augmentationType
- Type of augmentation to be returned- Returns:
- An instance of
A
- Throws:
NullPointerException
- ifaugmentationType
isnull
NoSuchElementException
- if the corresponding augmentation is not present- API Note:
- The design here follows
Optional.orElseThrow()
,
-
augmentationOrElseThrow
default <A extends Augmentation<T>,X extends Throwable> @NonNull A augmentationOrElseThrow(Class<A> augmentationType, Supplier<@NonNull X> exceptionSupplier) throws X Returns instance of augmentation, or throwsNoSuchElementException
.- Type Parameters:
A
- Type capture for augmentation typeX
- Type of the exception to be thrown- Parameters:
augmentationType
- Type of augmentation to be returnedexceptionSupplier
- the supplying function that produces an exception to be thrown- Returns:
- An instance of
A
- Throws:
NullPointerException
- ifaugmentationType
isnull
X
- if the corresponding augmentation is not present- API Note:
- The design here follows
Optional.orElseThrow(Supplier)
,
-
augmentations
@NonNull Map<Class<? extends Augmentation<T>>,Augmentation<T>> augmentations()Returns map of all augmentations.- Returns:
- map of all augmentations.
-