Top Description Inners Fields Constructors Methods
com.typesafe.config.impl

pack-priv abstract Class AbstractConfigValue

extends Object
implements ConfigValue, MergeableValue
Class Inheritance
All Implemented Interfaces
com.typesafe.config.impl.MergeableValue, com.typesafe.config.ConfigMergeable, com.typesafe.config.ConfigValue
Known Direct Subclasses
com.typesafe.config.impl.ConfigBoolean, com.typesafe.config.impl.ConfigConcatenation, com.typesafe.config.impl.ConfigDelayedMerge, com.typesafe.config.impl.ConfigNumber, com.typesafe.config.impl.ConfigReference, com.typesafe.config.impl.ConfigString, com.typesafe.config.impl.SerializedConfigValue, com.typesafe.config.impl.SimpleConfigList, com.typesafe.config.impl.ConfigNull, com.typesafe.config.impl.AbstractConfigObject
Imports
java.util.ArrayList, .Collection, .Collections, .List, .Map, com.typesafe.config.ConfigException, .ConfigMergeable, .ConfigObject, .ConfigOrigin, .ConfigRenderOptions, .ConfigValue

Trying very hard to avoid a parent reference in config values; when you have a tree like this, the availability of parent() tends to result in a lot of improperly-factored and non-modular code. Please don't add parent().

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static interface
protected abstract class
pack-priv static class
AbstractConfigValue.NotPossibleToResolve

This exception means that a value is inherently not resolveable, at the moment the only known cause is a cycle of substitutions.

Field Summary

Modifier and TypeField and Description
private final SimpleConfigOrigin

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected void
pack-priv SimpleConfig
atKey(ConfigOrigin origin, String key)

public SimpleConfig
atKey(String
key to store this value at.
key
)

Implements com.typesafe.config.ConfigValue.atKey.

Places the value inside a Config at the given key.

pack-priv SimpleConfig
atPath(ConfigOrigin origin, Path path)

public SimpleConfig
atPath(String
path to store this value at.
pathExpression
)

Implements com.typesafe.config.ConfigValue.atPath.

Places the value inside a Config at the given path.

protected boolean
protected AbstractConfigValue
private final AbstractConfigValue
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

protected static boolean
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

protected boolean
protected boolean
protected static void
indent(StringBuilder sb, int indent, ConfigRenderOptions options)

protected final AbstractConfigValue
protected AbstractConfigValue
protected final AbstractConfigValue
protected AbstractConfigValue
protected final AbstractConfigValue
protected AbstractConfigValue
protected abstract AbstractConfigValue
public SimpleConfigOrigin
origin()

Implements com.typesafe.config.ConfigValue.origin.

The origin of the value (file, line number, etc.), for debugging and error messages.

pack-priv AbstractConfigValue

Returns:

value relativized to the given path or the same value if nothing to do
relativized
(Path prefix)

This is used when including one file in another; the included file is relativized to the path it's included into in the parent file.

protected void
render(StringBuilder sb, int indent, boolean atRoot, String atKey, ConfigRenderOptions options)

protected void
render(StringBuilder sb, int indent, boolean atRoot, ConfigRenderOptions options)

public final String
render()

Implements com.typesafe.config.ConfigValue.render.

Renders the config value as a HOCON string.

public final String
render(ConfigRenderOptions
the rendering options
options
)

Implements com.typesafe.config.ConfigValue.render.

Renders the config value to a string, using the provided options.

protected static List<AbstractConfigValue>
protected final void
pack-priv ResolveStatus
pack-priv ResolveResult<? extends AbstractConfigValue>

Returns:

a new value if there were changes, or this if no changes
resolveSubstitutions
(ResolveContext
state of the current resolve
context
,
ResolveSource
where to look up values
source
)

Called only by ResolveContext.resolve().

public AbstractConfigValue
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

pack-priv String
public AbstractConfigValue
withFallback(ConfigMergeable
an object whose keys should be used as fallbacks, if the keys are not present in this one
mergeable
)

Implements com.typesafe.config.ConfigValue.withFallback, com.typesafe.config.ConfigMergeable.withFallback.

Returns a new value computed by merging this value with another, with keys in this value "winning" over the other one.

protected AbstractConfigValue
public AbstractConfigValue
withOrigin(ConfigOrigin
the origin set on the returned value
origin
)

Implements com.typesafe.config.ConfigValue.withOrigin.

Returns a ConfigValue based on this one, but with the given origin.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

originback to summary
private final SimpleConfigOrigin origin

Constructor Detail

AbstractConfigValueback to summary
pack-priv AbstractConfigValue(ConfigOrigin origin)

Method Detail

appendHiddenEnvVariableValueback to summary
protected void appendHiddenEnvVariableValue(StringBuilder sb)
atKeyback to summary
pack-priv SimpleConfig atKey(ConfigOrigin origin, String key)
atKeyback to summary
public SimpleConfig atKey(String key)

Implements com.typesafe.config.ConfigValue.atKey.

Doc from com.typesafe.config.ConfigValue.atKey.

Places the value inside a Config at the given key. See also ConfigValue#atPath(String).

Parameters
key:String

key to store this value at.

Returns:SimpleConfig

a Config instance containing this value at the given key.

Annotations
@Override
atPathback to summary
pack-priv SimpleConfig atPath(ConfigOrigin origin, Path path)
atPathback to summary
public SimpleConfig atPath(String pathExpression)

Implements com.typesafe.config.ConfigValue.atPath.

Doc from com.typesafe.config.ConfigValue.atPath.

Places the value inside a Config at the given path. See also ConfigValue#atKey(String).

Parameters
pathExpression:String

path to store this value at.

Returns:SimpleConfig

a Config instance containing this value at the given path.

Annotations
@Override
canEqualback to summary
protected boolean canEqual(Object other)
constructDelayedMergeback to summary
protected AbstractConfigValue constructDelayedMerge(ConfigOrigin origin, List<AbstractConfigValue> stack)
delayMergeback to summary
private final AbstractConfigValue delayMerge(Collection<AbstractConfigValue> stack, AbstractConfigValue fallback)
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hasDescendantInListback to summary
protected static boolean hasDescendantInList(List<AbstractConfigValue> list, AbstractConfigValue descendant)
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
hideEnvVariableValueback to summary
protected boolean hideEnvVariableValue(ConfigRenderOptions options)
ignoresFallbacksback to summary
protected boolean ignoresFallbacks()
indentback to summary
protected static void indent(StringBuilder sb, int indent, ConfigRenderOptions options)
mergedWithNonObjectback to summary
protected final AbstractConfigValue mergedWithNonObject(Collection<AbstractConfigValue> stack, AbstractConfigValue fallback)
mergedWithNonObjectback to summary
protected AbstractConfigValue mergedWithNonObject(AbstractConfigValue fallback)
mergedWithObjectback to summary
protected final AbstractConfigValue mergedWithObject(Collection<AbstractConfigValue> stack, AbstractConfigObject fallback)
mergedWithObjectback to summary
protected AbstractConfigValue mergedWithObject(AbstractConfigObject fallback)
mergedWithTheUnmergeableback to summary
protected final AbstractConfigValue mergedWithTheUnmergeable(Collection<AbstractConfigValue> stack, Unmergeable fallback)
mergedWithTheUnmergeableback to summary
protected AbstractConfigValue mergedWithTheUnmergeable(Unmergeable fallback)
newCopyback to summary
protected abstract AbstractConfigValue newCopy(ConfigOrigin origin)
originback to summary
public SimpleConfigOrigin origin()

Implements com.typesafe.config.ConfigValue.origin.

Doc from com.typesafe.config.ConfigValue.origin.

The origin of the value (file, line number, etc.), for debugging and error messages.

Returns:SimpleConfigOrigin

where the value came from

Annotations
@Override
relativizedback to summary
pack-priv AbstractConfigValue relativized(Path prefix)

This is used when including one file in another; the included file is relativized to the path it's included into in the parent file. The point is that if you include a file at foo.bar in the parent, and the included file as a substitution ${a.b.c}, the included substitution now needs to be ${foo.bar.a.b.c} because we resolve substitutions globally only after parsing everything.

Returns:AbstractConfigValue

value relativized to the given path or the same value if nothing to do

renderback to summary
protected void render(StringBuilder sb, int indent, boolean atRoot, String atKey, ConfigRenderOptions options)
renderback to summary
protected void render(StringBuilder sb, int indent, boolean atRoot, ConfigRenderOptions options)
renderback to summary
public final String render()

Implements com.typesafe.config.ConfigValue.render.

Doc from com.typesafe.config.ConfigValue.render.

Renders the config value as a HOCON string. This method is primarily intended for debugging, so it tries to add helpful comments and whitespace.

If the config value has not been resolved (see Config#resolve), it's possible that it can't be rendered as valid HOCON. In that case the rendering should still be useful for debugging but you might not be able to parse it. If the value has been resolved, it will always be parseable.

This method is equivalent to render(ConfigRenderOptions.defaults()).

Returns:String

the rendered value

Annotations
@Override
renderback to summary
public final String render(ConfigRenderOptions options)

Implements com.typesafe.config.ConfigValue.render.

Doc from com.typesafe.config.ConfigValue.render.

Renders the config value to a string, using the provided options.

If the config value has not been resolved (see Config#resolve), it's possible that it can't be rendered as valid HOCON. In that case the rendering should still be useful for debugging but you might not be able to parse it. If the value has been resolved, it will always be parseable.

If the config value has been resolved and the options disable all HOCON-specific features (such as comments), the rendering will be valid JSON. If you enable HOCON-only features such as comments, the rendering will not be valid JSON.

Parameters
options:ConfigRenderOptions

the rendering options

Returns:String

the rendered value

Annotations
@Override
replaceChildInListback to summary
protected static List<AbstractConfigValue> replaceChildInList(List<AbstractConfigValue> list, AbstractConfigValue child, AbstractConfigValue replacement)
requireNotIgnoringFallbacksback to summary
protected final void requireNotIgnoringFallbacks()
resolveStatusback to summary
pack-priv ResolveStatus resolveStatus()
resolveSubstitutionsback to summary
pack-priv ResolveResult<? extends AbstractConfigValue> resolveSubstitutions(ResolveContext context, ResolveSource source) throws NotPossibleToResolve

Called only by ResolveContext.resolve().

Parameters
context:ResolveContext

state of the current resolve

source:ResolveSource

where to look up values

Returns:ResolveResult<? extends AbstractConfigValue>

a new value if there were changes, or this if no changes

toFallbackValueback to summary
public AbstractConfigValue toFallbackValue()

Implements com.typesafe.config.impl.MergeableValue.toFallbackValue.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
transformToStringback to summary
pack-priv String transformToString()
withFallbackback to summary
public AbstractConfigValue withFallback(ConfigMergeable mergeable)

Implements com.typesafe.config.ConfigValue.withFallback, com.typesafe.config.ConfigMergeable.withFallback.

Doc from com.typesafe.config.ConfigMergeable.withFallback.

Returns a new value computed by merging this value with another, with keys in this value "winning" over the other one.

This associative operation may be used to combine configurations from multiple sources (such as multiple configuration files).

The semantics of merging are described in the spec for HOCON. Merging typically occurs when either the same object is created twice in the same file, or two config files are both loaded. For example:

 foo = { a: 42 }
 foo = { b: 43 }
Here, the two objects are merged as if you had written:
 foo = { a: 42, b: 43 }

Only ConfigObject and Config instances do anything in this method (they need to merge the fallback keys into themselves). All other values just return the original value, since they automatically override any fallback. This means that objects do not merge "across" non-objects; if you write object.withFallback(nonObject).withFallback(otherObject), then otherObject will simply be ignored. This is an intentional part of how merging works, because non-objects such as strings and integers replace (rather than merging with) any prior value:

foo = { a: 42 }
foo = 10
Here, the number 10 "wins" and the value of foo would be simply 10. Again, for details see the spec.
Parameters
mergeable:ConfigMergeable

an object whose keys should be used as fallbacks, if the keys are not present in this one

Returns:AbstractConfigValue

a new object (or the original one, if the fallback doesn't get used)

Annotations
@Override
withFallbacksIgnoredback to summary
protected AbstractConfigValue withFallbacksIgnored()
withOriginback to summary
public AbstractConfigValue withOrigin(ConfigOrigin origin)

Implements com.typesafe.config.ConfigValue.withOrigin.

Doc from com.typesafe.config.ConfigValue.withOrigin.

Returns a ConfigValue based on this one, but with the given origin. This is useful when you are parsing a new format of file or setting comments for a single ConfigValue.

Parameters
origin:ConfigOrigin

the origin set on the returned value

Returns:AbstractConfigValue

the new ConfigValue with the given origin

Annotations
@Override
com.typesafe.config.impl back to summary

protected Interface AbstractConfigValue.Modifier

Known Direct Implementers
com.typesafe.config.impl.AbstractConfigValue.NoExceptionsModifier, com.typesafe.config.impl.SimpleConfigList.ResolveModifier, com.typesafe.config.impl.SimpleConfigObject.ResolveModifier

Method Summary

Modifier and TypeMethod and Description
public AbstractConfigValue

Method Detail

modifyChildMayThrowback to summary
public AbstractConfigValue modifyChildMayThrow(String keyOrNull, AbstractConfigValue v) throws Exception
com.typesafe.config.impl back to summary

protected abstract Class AbstractConfigValue.NoExceptionsModifier

extends Object
implements Modifier
Class Inheritance
  • java.lang.Object
  • com.typesafe.config.impl.AbstractConfigValue.NoExceptionsModifier
All Implemented Interfaces
com.typesafe.config.impl.AbstractConfigValue.Modifier

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract AbstractConfigValue
public final AbstractConfigValue
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NoExceptionsModifierback to summary
protected NoExceptionsModifier()

Method Detail

modifyChildback to summary
pack-priv abstract AbstractConfigValue modifyChild(String keyOrNull, AbstractConfigValue v)
modifyChildMayThrowback to summary
public final AbstractConfigValue modifyChildMayThrow(String keyOrNull, AbstractConfigValue v) throws Exception

Implements com.typesafe.config.impl.AbstractConfigValue.Modifier.modifyChildMayThrow.

Annotations
@Override
com.typesafe.config.impl back to summary

pack-priv Class AbstractConfigValue.NotPossibleToResolve

extends Exception
Class Inheritance

This exception means that a value is inherently not resolveable, at the moment the only known cause is a cycle of substitutions. This is a checked exception since it's internal to the library and we want to be sure we handle it before passing it out to public API. This is only supposed to be thrown by the target of a cyclic reference and it's supposed to be caught by the ConfigReference looking up that reference, so it should be impossible for an outermost resolve() to throw this. Contrast with ConfigException.NotResolved which just means nobody called resolve().

Field Summary

Modifier and TypeField and Description
private static final long
private final String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv String

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.Exception.serialVersionUID.

traceStringback to summary
private final String traceString

Constructor Detail

NotPossibleToResolveback to summary
pack-priv NotPossibleToResolve(ResolveContext context)

Method Detail

traceStringback to summary
pack-priv String traceString()