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 Details

    • augmentation

      default <A extends Augmentation<T>> @Nullable A augmentation(Class<A> augmentationType)
      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, or null if the augmentationType is not present
      Throws:
      NullPointerException - if augmentationType is null
    • augmentationOrElseThrow

      default <A extends Augmentation<T>> @NonNull A augmentationOrElseThrow(Class<A> augmentationType)
      Returns instance of augmentation, or throws NoSuchElementException.
      Type Parameters:
      A - Type capture for augmentation type
      Parameters:
      augmentationType - Type of augmentation to be returned
      Returns:
      An instance of A
      Throws:
      NullPointerException - if augmentationType is null
      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 throws NoSuchElementException.
      Type Parameters:
      A - Type capture for augmentation type
      X - Type of the exception to be thrown
      Parameters:
      augmentationType - Type of augmentation to be returned
      exceptionSupplier - the supplying function that produces an exception to be thrown
      Returns:
      An instance of A
      Throws:
      NullPointerException - if augmentationType is null
      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.