public class ConfigurationBuilderImpl extends Object implements ConfigurationBuilder
Modifier and Type | Field and Description |
---|---|
static String |
IMPORT |
static String |
INIT |
ClassHierarchy |
namespace |
Modifier and Type | Method and Description |
---|---|
void |
addConfiguration(Configuration conf)
Add all configuration parameters from the given Configuration object.
|
void |
bind(Node key,
Node value)
Bind classes to each other, based on their full class names; alternatively,
bound a NamedParameter configuration option to a configuration value.
|
<T> void |
bind(String key,
String value)
Bind classes to each other, based on their full class names; alternatively,
bound a NamedParameter configuration option to a configuration value.
|
<T> void |
bindConstructor(ClassNode<T> k,
ClassNode<? extends ExternalConstructor<? extends T>> v)
Register an ExternalConstructor implementation with Tang.
|
<T> void |
bindImplementation(ClassNode<T> n,
ClassNode<? extends T> m) |
<T> void |
bindList(NamedParameterNode<List<T>> iface,
List implList)
Bind an list of implementations(Class or String) to an given NamedParameter.
|
void |
bindList(String iface,
List implList) |
<T> void |
bindParameter(NamedParameterNode<T> name,
String value) |
<T> void |
bindSetEntry(NamedParameterNode<Set<T>> iface,
Node impl) |
<T> void |
bindSetEntry(NamedParameterNode<Set<T>> iface,
String impl) |
void |
bindSetEntry(String iface,
Node impl) |
void |
bindSetEntry(String iface,
String impl) |
ConfigurationImpl |
build()
Produce an immutable Configuration object that contains the current
bindings and ClassHierarchy of this ConfigurationBuilder.
|
String |
classPrettyDefaultString(String longName)
Pretty print the default implementation / value of the provided class / NamedParamter.
|
String |
classPrettyDescriptionString(String fullName)
Pretty print the human readable documentation of the provided class / NamedParamter.
|
boolean |
equals(Object o) |
ClassHierarchy |
getClassHierarchy()
Each ConfigurationBuilder instance is associated with a ClassHierarchy.
|
int |
hashCode() |
void |
registerLegacyConstructor(ClassNode<?> cn,
ClassNode<?>... args)
Force Tang to treat the specified constructor as though it had an @Inject
annotation.
|
void |
registerLegacyConstructor(ClassNode<?> c,
ConstructorArg... args)
Force Tang to treat the specified constructor as though it had an @Inject
annotation.
|
void |
registerLegacyConstructor(String s,
String... args)
Force Tang to treat the specified constructor as though it had an @Inject
annotation.
|
public static final String IMPORT
public static final String INIT
public ClassHierarchy namespace
public void addConfiguration(Configuration conf) throws BindException
ConfigurationBuilder
addConfiguration
in interface ConfigurationBuilder
BindException
public ClassHierarchy getClassHierarchy()
ConfigurationBuilder
getClassHierarchy
in interface ConfigurationBuilder
public void registerLegacyConstructor(ClassNode<?> c, ConstructorArg... args) throws BindException
ConfigurationBuilder
registerLegacyConstructor
in interface ConfigurationBuilder
args
- The parsed ConstructorArg objects correspdonding to the types of the arguments taken by the constructor, in declaration order.BindException
- if the constructor does not exist, or if it has already been bound as a legacy constructor.public void registerLegacyConstructor(String s, String... args) throws BindException
ConfigurationBuilder
registerLegacyConstructor
in interface ConfigurationBuilder
s
- The full name of the class the constructor instantiates.args
- The full names of the types of the arguments taken by the constructor, in declaration order.BindException
- if the constructor does not exist, or if it has already been bound as a legacy constructor.public void registerLegacyConstructor(ClassNode<?> cn, ClassNode<?>... args) throws BindException
ConfigurationBuilder
registerLegacyConstructor
in interface ConfigurationBuilder
cn
- The class the constructor instantiates.args
- The types of the arguments taken by the constructor, in declaration order.BindException
- if the constructor does not exist, or if it has already been bound as a legacy constructor.public <T> void bind(String key, String value) throws BindException
ConfigurationBuilder
bind
in interface ConfigurationBuilder
key
- The full name of the interface that should resolve to impl,
or the NamedParameter to be set.value
- The full name of the implementation that will be used in
place of impl, or the value the NamedParameter should be set to.BindException
- If (In the case of interfaces and implementations)
the underlying ClassHierarchy does not recognice iface and
impl as known, valid classes, or if impl is not a in
implementation of iface, or (in the case of NamedParameters
and values) if iface is not a NamedParameter, or if impl
fails to parse as the type the iface expects.public void bind(Node key, Node value) throws BindException
ConfigurationBuilder
bind
in interface ConfigurationBuilder
BindException
- if there is a type checking errorfor a more complete description.
public <T> void bindImplementation(ClassNode<T> n, ClassNode<? extends T> m) throws BindException
BindException
public <T> void bindParameter(NamedParameterNode<T> name, String value) throws BindException
BindException
public void bindSetEntry(String iface, String impl) throws BindException
bindSetEntry
in interface ConfigurationBuilder
BindException
public void bindSetEntry(String iface, Node impl) throws BindException
bindSetEntry
in interface ConfigurationBuilder
BindException
public <T> void bindSetEntry(NamedParameterNode<Set<T>> iface, String impl) throws BindException
bindSetEntry
in interface ConfigurationBuilder
BindException
public <T> void bindSetEntry(NamedParameterNode<Set<T>> iface, Node impl) throws BindException
bindSetEntry
in interface ConfigurationBuilder
BindException
public <T> void bindList(NamedParameterNode<List<T>> iface, List implList)
ConfigurationBuilder
bindList
in interface ConfigurationBuilder
iface
- The list named parameter to be instantiatedimplList
- The list of class or value will be used to instantiated the named parameterpublic void bindList(String iface, List implList)
bindList
in interface ConfigurationBuilder
public <T> void bindConstructor(ClassNode<T> k, ClassNode<? extends ExternalConstructor<? extends T>> v)
ConfigurationBuilder
bindConstructor
in interface ConfigurationBuilder
k
- The class or interface to be instantiated.v
- The ExternalConstructor class that will be used to instantiate iface.public ConfigurationImpl build()
ConfigurationBuilder
build
in interface ConfigurationBuilder
public String classPrettyDefaultString(String longName) throws NameResolutionException
ConfigurationBuilder
classPrettyDefaultString
in interface ConfigurationBuilder
NameResolutionException
public String classPrettyDescriptionString(String fullName) throws NameResolutionException
ConfigurationBuilder
classPrettyDescriptionString
in interface ConfigurationBuilder
NameResolutionException
Copyright © 2015 The Apache Software Foundation. All rights reserved.