Class ResourceDecoratorRegistry

java.lang.Object
com.kazforge.jsonapi.mapping.ResourceDecoratorRegistry

public final class ResourceDecoratorRegistry extends Object
Immutable registry of ResourceDecorator instances keyed by application domain type.

Lookup is exact-match on the effective runtime type's raw class; subclasses require their own registration. The registry is safe for concurrent use once created. It is not a global mutable registry — supply it through mapper construction.

Registered decorators are stored by reference and reused for every mapping call. When a mapper created from this registry is shared across threads, each decorator must be safe for concurrent invocation.

Resolution is deterministic: at most one decorator per raw class, no prefix or type-string indirection, and no dependence on JSON:API type strings.

  • Method Details

    • empty

      public static ResourceDecoratorRegistry empty()
      Returns an empty registry (no decorators).
    • of

      public static ResourceDecoratorRegistry of(Map<Class<?>,ResourceDecorator<?>> decorators)
      Returns a registry copied from the given map (defensive copy, unmodifiable).
    • builder

      public static ResourceDecoratorRegistry.Builder builder()
      Creates a builder for one immutable registry.
    • decoratorFor

      public <T> @Nullable ResourceDecorator<T> decoratorFor(Class<T> type)
      Returns the decorator for the given raw domain class, if any, via an exact match on raw class.
    • size

      public int size()
      Returns the number of registered decorators.
    • isEmpty

      public boolean isEmpty()
      Returns true when no decorators are registered.
    • asMap

      public Map<Class<?>,ResourceDecorator<?>> asMap()
      Returns an unmodifiable view of the underlying map.