Class HalEnricherContext

java.lang.Object
sonia.scm.api.v2.resources.HalEnricherContext

public final class HalEnricherContext extends Object
Context object for the HalEnricher. The context holds the source object for the json and all related objects, which can be useful for the enrichment.
Since:
2.0.0
  • Method Details

    • of

      public static HalEnricherContext of(Object... instances)
      Creates a context with the given entries
      Parameters:
      instances - entries of the context
    • builder

      public static HalEnricherContext.Builder builder()
      Return builder for HalEnricherContext.
      Since:
      2.23.0
    • oneByType

      public <T> Optional<T> oneByType(Class<T> type)
      Returns the registered object from the context. The method will return an empty optional, if no object with the given type was registered.
      Type Parameters:
      T - type of instance
      Parameters:
      type - type of instance
      Returns:
      optional instance
    • oneRequireByType

      public <T> T oneRequireByType(Class<T> type)
      Returns the registered object from the context, but throws an NoSuchElementException if the type was not registered.
      Type Parameters:
      T - type of instance
      Parameters:
      type - type of instance
      Returns:
      instance