Class MappingPropertySkeleton<K,V>

java.lang.Object
dev.goldmensch.propane.property.MappingPropertySkeleton<K,V>
Type Parameters:
K - the java type of the key
V - the java type of the value
All Implemented Interfaces:
Property<Map<K,V>>, Property.MultiValue<Map<K,V>>

public abstract non-sealed class MappingPropertySkeleton<K,V> extends Object implements Property.MultiValue<Map<K,V>>

A MappingProperty represents a Map. It has one key type and one value type.

For example, think of validators that should validate request parameters based on their type. These validators can be registered via a MappingPropertySkeleton<Class, Validator>, basically representing an Map<Class, Validator>.

If multiple PropertyProviders are registered for this property at the same introspection instance, all values are combined and the ones from a provider with a higher priority override the values of the ones from provider with a lower priority. (think of Map.put(Object, Object)). For information on how fallback values are trod, visit the documentation of Property.FallbackStrategy.

If you have multiple PropertyProviders registered at different introspection instances, that are related to each other (the one is child of the other), the above applies for each introspection instance itself. The final value is then computed by combining all values under the rule that values from a child override the parents' ones.

For example, take a look here (simplified API):

IntrospectionSkeleton A = IntrospectionImplSkeleton.create(Scopes.ROOT)
    .addBuilder(Property.MAPPING, _ -> Map.of("foo", "Value A Builder")) // builder has higher priority than fallback
    .addFallback(Property.MAPPING, _ -> Map.of("foo", "Value A Fallback"))
    .build();

A.get(Property.MAPPING).get("foo") // returns "Value A Builder"

IntrospectionSkeleton B = A.createChild(Scopes.ROOT)
    .addFallback(Property.MAPPING, _ -> Map.of("foo", "Value B"))
    .build();

B.get(Property.MAPPING).get("foo") // returns "Value B"
See Also: