Package com.kazforge.jsonapi.mapping
Class ResourceDecoratorRegistry
java.lang.Object
com.kazforge.jsonapi.mapping.ResourceDecoratorRegistry
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classMutable builder whoseResourceDecoratorRegistry.Builder.build()result defensively copies supplied values. -
Method Summary
Modifier and TypeMethodDescriptionMap<Class<?>, ResourceDecorator<?>> asMap()Returns an unmodifiable view of the underlying map.builder()Creates a builder for one immutable registry.<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.static ResourceDecoratorRegistryempty()Returns an empty registry (no decorators).booleanisEmpty()Returnstruewhen no decorators are registered.static ResourceDecoratorRegistryof(Map<Class<?>, ResourceDecorator<?>> decorators) Returns a registry copied from the given map (defensive copy, unmodifiable).intsize()Returns the number of registered decorators.
-
Method Details
-
empty
Returns an empty registry (no decorators). -
of
Returns a registry copied from the given map (defensive copy, unmodifiable). -
builder
Creates a builder for one immutable registry. -
decoratorFor
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()Returnstruewhen no decorators are registered. -
asMap
Returns an unmodifiable view of the underlying map.
-