public interface Configuration
Tang Configuration objects are constructed via ConfigurationBuilders, and most applications interact with the Configuration API much more than the one described here. See the ConfigurationBuilder documentation for a discussion of the semantics of configuration options. The documentation provided here is primarily for people that wish to extend Tang or implement formats that export data from Configuration objects to other systems.
Conceptually, a configuration contains a set of key value pairs. Each pair either maps from an interface to an implementation (a class) or from a configuration option to a value (e.g., an integer or string).
Under the hood, Configuration objects carry much richer type information than this, and also refer to the ClassHierarchy object they were checked against. Configurations can be merged into each other by creating a new ConfigurationBuilder object, and passing in multiple configurations. In such situations, Tang automatically merges the reflection data from the underlying ClassHierarchy objects, and re-validates the merged configuration data against the merged classpath.
Note that the left hand side of each configuration object (the "key" in the key value pair) is unique. Although there are many APIs that take NamedParameterNode objects in this API, a given NamedParameterNode represents a unique type of binding, and is only applicable to one of the getters below. These APIs use Java generic types to make it easier to map from NamedParameterNode to the appropriate getter.
Modifier and Type | Method and Description |
---|---|
<T> ClassNode<ExternalConstructor<T>> |
getBoundConstructor(ClassNode<T> cn)
Return the bound constructor.
|
Set<ClassNode<?>> |
getBoundConstructors() |
<T> ClassNode<T> |
getBoundImplementation(ClassNode<T> cn)
Returns the bound implementation.
|
Set<ClassNode<?>> |
getBoundImplementations() |
List<Object> |
getBoundList(NamedParameterNode<List<?>> np)
Get the list bound to a given NamedParameterNode.
|
Set<NamedParameterNode<List<?>>> |
getBoundLists() |
Set<Object> |
getBoundSet(NamedParameterNode<Set<?>> np)
Obtain the set of class hierarchy nodes or strings that were bound to a given NamedParameterNode.
|
Set<NamedParameterNode<Set<?>>> |
getBoundSets() |
ClassHierarchy |
getClassHierarchy()
Configuration objects are associated with the ClassHierarchy objects that were used during validation.
|
<T> ConstructorDef<T> |
getLegacyConstructor(ClassNode<T> cn)
Return the LegacyConstructor that has been bound to this Class.
|
Set<ClassNode<?>> |
getLegacyConstructors() |
String |
getNamedParameter(NamedParameterNode<?> np)
Return the value of the given named parameter as an unparsed string.
|
Set<NamedParameterNode<?>> |
getNamedParameters() |
ConfigurationBuilder |
newBuilder()
Create a new ConfigurationBuilder object based on the same classpath
as this Configuration, and populate it with the configuration options
of this object.
|
ConfigurationBuilder newBuilder()
This API is unstable and should be considered private. Use the methods in org.apache.reef.Tang instead.
String getNamedParameter(NamedParameterNode<?> np)
If nothing was explicitly bound, this method returns null (it does not return default values).
np
- A NamedParameter object from this Configuration's class hierarchy.getClassHierarchy()
Set<Object> getBoundSet(NamedParameterNode<Set<?>> np)
np
- A NamedParameterNode from this Configuration's class hierarchy.getClassHierarchy()
List<Object> getBoundList(NamedParameterNode<List<?>> np)
np
- Target NamedParameter<T> ClassNode<ExternalConstructor<T>> getBoundConstructor(ClassNode<T> cn)
T
- a typecn
- a class node<T> ClassNode<T> getBoundImplementation(ClassNode<T> cn)
T
- a typecn
- a class node<T> ConstructorDef<T> getLegacyConstructor(ClassNode<T> cn)
For now, only one legacy constructor can be bound per class.
TODO: Should this return Set<ConstructorDef<T>>
instead?
T
- a typecn
- a class nodeSet<ClassNode<?>> getBoundImplementations()
Set<ClassNode<?>> getBoundConstructors()
Set<NamedParameterNode<?>> getNamedParameters()
Set<ClassNode<?>> getLegacyConstructors()
ClassHierarchy getClassHierarchy()
Set<NamedParameterNode<Set<?>>> getBoundSets()
Set<NamedParameterNode<List<?>>> getBoundLists()
Copyright © 2017 The Apache Software Foundation. All rights reserved.