Package org.pkl.config.java
Interface Config
public interface Config
A root, intermediate, or leaf node in a configuration tree. Child nodes can be obtained by name
using
get(String). To consume the node's composite or scalar value, convert the value to
the desired Java type, using one of the provided as(java.lang.Class<T>) methods.-
Method Summary
Modifier and TypeMethodDescription<T> TConverts this node's value to the givenClass.<T> TConverts this node's value to the givenType.<T> TConverts this node's value to the givenJavaType.static ConfigfromPklBinary(byte[] bytes) Decode a config from the supplied byte array using a preconfiguredValueMapper.static ConfigfromPklBinary(byte[] bytes, ValueMapper mapper) Decode a config from the supplied byte array.static ConfigfromPklBinary(InputStream inputStream) Decode a config from the suppliedInputStream.static ConfigfromPklBinary(InputStream inputStream, ValueMapper mapper) Decode a config from the suppliedInputStreamusing a preconfiguredValueMapper.Returns the child node with the given unqualified name.The dot-separated name of this node.The raw value of this node, as provided byEvaluator.
-
Method Details
-
getQualifiedName
String getQualifiedName()The dot-separated name of this node. For example, the node reached usingrootNode.get("foo").get("bar")has qualified namefoo.bar. Returns the empty String for the root node itself. -
getRawValue
Object getRawValue()The raw value of this node, as provided byEvaluator. Typically, a node's value is not consumed directly, but converted to the desired Java type usingas(java.lang.Class<T>). -
get
Returns the child node with the given unqualified name.- Throws:
NoSuchChildException- if a child with the given name does not exist
-
as
Converts this node's value to the givenClass.- Throws:
ConversionException- if the value cannot be converted to the given type
-
as
Converts this node's value to the givenType.Note that usages of this method are not type safe.
- Throws:
ConversionException- if the value cannot be converted to the given type
-
as
Converts this node's value to the givenJavaType.- Throws:
ConversionException- if the value cannot be converted to the given type
-
fromPklBinary
Decode a config from the supplied byte array.- Returns:
- the encoded config
-
fromPklBinary
Decode a config from the supplied byte array using a preconfiguredValueMapper.- Returns:
- the encoded config
-
fromPklBinary
Decode a config from the suppliedInputStreamusing a preconfiguredValueMapper.- Returns:
- the encoded config
-
fromPklBinary
Decode a config from the suppliedInputStream.- Returns:
- the encoded config
-