public class ConfigInheritances
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ConfigInheritances.BasicConfigValueAtContainer<TContainer,TValue> |
Constructor and Description |
---|
ConfigInheritances() |
Modifier and Type | Method and Description |
---|---|
static ConfigInheritance |
findInheritance(ConfigKey<?> localKey,
ConfigInheritance.ConfigInheritanceContext context,
ConfigInheritance defaultInheritance) |
static ConfigInheritance |
findInheritance(ConfigValueAtContainer<?,?> local,
ConfigInheritance.ConfigInheritanceContext context,
ConfigInheritance defaultInheritance)
finds the
ConfigInheritance to use based on the given container, or the default if none is present there |
static <T> boolean |
isKeyReinheritable(ConfigKey<T> key,
ConfigInheritance.ConfigInheritanceContext context)
determine whether a key is reinheritable from the point in the given inheritance hierarchy where it is introduced;
default is true, but some keys may define not being reinherited or may have that effective result
|
static <TContainer,TValue> |
resolveInheriting(ConfigValueAtContainer<TContainer,TValue> local,
java.util.Iterator<? extends ConfigValueAtContainer<TContainer,TValue>> ancestorContainerKeyValues,
ConfigKey<TValue> queryKey,
ConfigInheritance.ConfigInheritanceContext context,
ConfigInheritance defaultInheritance)
as
#resolveInheriting(Object, ConfigKey, Maybe, Maybe, Iterator, ConfigInheritanceContext, ConfigInheritance)
but convenient when the local info is already in a ConfigValueAtContainer |
static <TContainer,TValue> |
resolveInheriting(TContainer container,
ConfigKey<TValue> key,
Maybe<TValue> localValue,
Maybe<TValue> defaultValue,
java.util.Iterator<? extends ConfigValueAtContainer<TContainer,TValue>> ancestorContainerKeyValues,
ConfigInheritance.ConfigInheritanceContext context,
ConfigInheritance defaultInheritance)
given a key and local value, together with an optional record of ancestor containers (eg an entity) and associated data,
this finds the value for a config key applying the appropriate inheritance strategies.
|
public static <TContainer,TValue> ReferenceWithError<ConfigValueAtContainer<TContainer,TValue>> resolveInheriting(@Nullable TContainer container, ConfigKey<TValue> key, @Nullable Maybe<TValue> localValue, @Nullable Maybe<TValue> defaultValue, java.util.Iterator<? extends ConfigValueAtContainer<TContainer,TValue>> ancestorContainerKeyValues, ConfigInheritance.ConfigInheritanceContext context, ConfigInheritance defaultInheritance)
this uses an interface on the input so that: - the caller can supply the hierarchy - hierarchy is only traversed as far as needed - caller can do full resolution as required for local values
this returns in interface so that caller can get the value, and if needed also find the container where the key is defined. that can be useful for when the value needs to be further resolved, e.g. a DSL function or a URL. the returned value may be evaluated lazily, i.e. the actual traversal and evaluation may be deferred until a method on the returned object is invoked.
this object is taken as the default inheritance and used if no inheritance is defined on the key.
so that the caller can determine if a key/value is to be exported to children from a container, this method should accept an iterable whose first entry has a null container and whose second entry gives the container, key, and potential value to be exported. if null is returned the caller knows nothing is to be exported to children.
public static <TContainer,TValue> ReferenceWithError<ConfigValueAtContainer<TContainer,TValue>> resolveInheriting(ConfigValueAtContainer<TContainer,TValue> local, java.util.Iterator<? extends ConfigValueAtContainer<TContainer,TValue>> ancestorContainerKeyValues, ConfigKey<TValue> queryKey, ConfigInheritance.ConfigInheritanceContext context, ConfigInheritance defaultInheritance)
#resolveInheriting(Object, ConfigKey, Maybe, Maybe, Iterator, ConfigInheritanceContext, ConfigInheritance)
but convenient when the local info is already in a ConfigValueAtContainer
public static ConfigInheritance findInheritance(ConfigValueAtContainer<?,?> local, ConfigInheritance.ConfigInheritanceContext context, ConfigInheritance defaultInheritance)
ConfigInheritance
to use based on the given container, or the default if none is present therepublic static ConfigInheritance findInheritance(ConfigKey<?> localKey, ConfigInheritance.ConfigInheritanceContext context, ConfigInheritance defaultInheritance)
public static <T> boolean isKeyReinheritable(ConfigKey<T> key, ConfigInheritance.ConfigInheritanceContext context)
note that this does not mean a value should never be *inherited*; callers should query with the key defined at a given point in a hierarchy, so if a key is not defined at some point in the hierarchy (eg not on a type in the type hierarchy, or not an an entity in the runtime management hierarchy) then null should be passed and values will be reinheritable