public class BasicConfigInheritance extends java.lang.Object implements ConfigInheritance
Modifier and Type | Class and Description |
---|---|
static class |
BasicConfigInheritance.DelegatingConfigInheritance
This class allows us to have constant instances of
ConfigInheritance
which have no internal fields (ie they don't extend BasicConfigInheritance )
so are pretty on serialization, but otherwise act identically. |
ConfigInheritance.ConfigInheritanceContext, ConfigInheritance.InheritanceMode, ConfigInheritance.Legacy
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CONFLICT_RESOLUTION_STRATEGY_DEEP_MERGE |
static java.lang.String |
CONFLICT_RESOLUTION_STRATEGY_OVERWRITE |
static ConfigInheritance |
DEEP_MERGE
Indicates that if a key has a value at both an ancestor and a descendant, the descendant and his descendants
should attempt to merge the values.
|
static ConfigInheritance |
NEVER_INHERITED
Indicates that a key's value should never be inherited, even if inherited from a value set on a container that does not know the key.
|
static ConfigInheritance |
NOT_REINHERITED
Indicates that a config key value should not be passed down from a container where it is defined.
|
static ConfigInheritance |
NOT_REINHERITED_ELSE_DEEP_MERGE
As
NOT_REINHERITED but in cases where a value is inherited because a parent did not recognize it,
if the inheritor also defines a value the two values should be merged. |
static ConfigInheritance |
OVERWRITE
Indicates that if a key has a value at both an ancestor and a descendant, the descendant and his descendants
will prefer the value at the descendant.
|
ALWAYS, NONE
Modifier and Type | Method and Description |
---|---|
<TContainer,TValue> |
considerParent(ConfigValueAtContainer<TContainer,TValue> local,
ConfigValueAtContainer<TContainer,TValue> parent,
ConfigInheritance.ConfigInheritanceContext context)
Returns whether any value from the parent or its ancestors should be considered
by the given local container, according to the
ConfigInheritance defined there. |
boolean |
equals(java.lang.Object obj) |
static ConfigInheritance |
fromString(java.lang.String val) |
boolean |
getAncestorDefaultInheritable() |
java.lang.String |
getConflictResolutionStrategy() |
boolean |
getLocalDefaultResolvesWithAncestorValue()
|
boolean |
getUseLocalDefaultValue()
Deprecated.
|
int |
hashCode() |
ConfigInheritance.InheritanceMode |
isInherited(ConfigKey<?> key,
java.lang.Object from,
java.lang.Object to)
Deprecated.
|
<TContainer,TValue> |
isReinheritable(ConfigValueAtContainer<TContainer,TValue> parent,
ConfigInheritance.ConfigInheritanceContext context)
Returns whether any value from the given node or ancestors can be considered
for inheritance by descendants, according to the
ConfigInheritance defined there. |
boolean |
isReinherited() |
<TContainer,TValue> |
resolveWithParent(ConfigValueAtContainer<TContainer,TValue> local,
ConfigValueAtContainer<TContainer,TValue> parent,
ConfigInheritance.ConfigInheritanceContext context)
Returns the result after inheritance between the local container and a "resolveParent"
representation of the parent's evaluation of the key considering its ancestors.
|
java.lang.String |
toString() |
public static final java.lang.String CONFLICT_RESOLUTION_STRATEGY_DEEP_MERGE
public static final java.lang.String CONFLICT_RESOLUTION_STRATEGY_OVERWRITE
public static final ConfigInheritance NOT_REINHERITED
NEVER_INHERITED
these values can be passed down if set as anonymous keys at a container
(ie the container does not expect it) to a container which does expect it, but it will not be passed down further.
If the inheritor also defines a value the parent's value is ignored irrespective
(as in OVERWRITE
; see NOT_REINHERITED_ELSE_DEEP_MERGE
if merging is desired).public static final ConfigInheritance NOT_REINHERITED_ELSE_DEEP_MERGE
NOT_REINHERITED
but in cases where a value is inherited because a parent did not recognize it,
if the inheritor also defines a value the two values should be merged.public static final ConfigInheritance NEVER_INHERITED
NOT_REINHERITED
.)public static final ConfigInheritance OVERWRITE
public static final ConfigInheritance DEEP_MERGE
@Deprecated public ConfigInheritance.InheritanceMode isInherited(ConfigKey<?> key, java.lang.Object from, java.lang.Object to)
isInherited
in interface ConfigInheritance
public <TContainer,TValue> boolean isReinheritable(ConfigValueAtContainer<TContainer,TValue> parent, ConfigInheritance.ConfigInheritanceContext context)
ConfigInheritance
ConfigInheritance
defined there.
The implementation of this method is usually a constant depending on the inheritance in effect;
in particular it will not normally consider any values or inform whether something should be inherited:
it is only advising whether inheritance is permitted from a given point in the inheritance hierarchy.
If there is a ConfigInheritance
defined at this node,
this method must be called on that instance and that instance only.
In that case it is an error to invoke this method on any other ConfigInheritance
instance.
If there is not one, the config generally should be considered reinheritable.
Key inference (continuing from the above): Callers should not try to infer any descendant key and look at what it says about reinheritability; if a container does not define a key it would be pointless for it not to be reinheritable).
Consumers will typically find the methods in ConfigInheritances
more convenient.
isReinheritable
in interface ConfigInheritance
public <TContainer,TValue> boolean considerParent(ConfigValueAtContainer<TContainer,TValue> local, ConfigValueAtContainer<TContainer,TValue> parent, ConfigInheritance.ConfigInheritanceContext context)
ConfigInheritance
ConfigInheritance
defined there.
This defines the ConfigInheritance
of the local container typically considering
the value of the key there.
Implementations should not normally consider the value of the parent
as there may be other ancestors whose values have not yet been considered and are not supplied,
but it may determine that a local value is sufficient to render it unnecessary to consider the parent.
If there is a ConfigInheritance
defined at the local container,
this method must be called on that instance and that instance only.
In that case it is an error to invoke this method on any other ConfigInheritance
instance.
Key inference: if a container does not define a key, the inheritance in the key definition in the nearest descendant of that container should be used.
Consumers should consider this in conjuction with the
ConfigInheritance.isReinheritable(ConfigValueAtContainer, ConfigInheritanceContext)
status of the parent (if present).
Implementers need not duplicate a call to that method.
Consumers will typically find the methods in ConfigInheritances
more convenient.
considerParent
in interface ConfigInheritance
public <TContainer,TValue> ReferenceWithError<ConfigValueAtContainer<TContainer,TValue>> resolveWithParent(ConfigValueAtContainer<TContainer,TValue> local, ConfigValueAtContainer<TContainer,TValue> parent, ConfigInheritance.ConfigInheritanceContext context)
ConfigInheritance
ConfigInheritance.considerParent(ConfigValueAtContainer, ConfigValueAtContainer, ConfigInheritanceContext)
on the local node and ConfigInheritance.isReinheritable(ConfigValueAtContainer, ConfigInheritanceContext)
on the original parent node,
and then ConfigInheritance.resolveWithParent(ConfigValueAtContainer, ConfigValueAtContainer, ConfigInheritanceContext)
on the original parent node with its respective resolvedParent.
If there is a ConfigInheritance
defined at the local container,
this method must be called on that instance and that instance only.
In that case it is an error to invoke this method on any other ConfigInheritance
instance.
Key inference: if a container does not define a key, the inheritance in the key definition in the nearest descendant of that container should be used.
Consumers will typically find the methods in ConfigInheritances
more convenient.
resolveWithParent
in interface ConfigInheritance
public boolean isReinherited()
public java.lang.String getConflictResolutionStrategy()
@Deprecated public boolean getUseLocalDefaultValue()
public boolean getLocalDefaultResolvesWithAncestorValue()
public boolean getAncestorDefaultInheritable()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static ConfigInheritance fromString(java.lang.String val)