public class BindingDSL extends AbstractConfigContext
The fact that this extends AbstractConfigContext
is basically an implementation
detail, to make sure that we always provide proxies for all the methods.
Modifier and Type | Method and Description |
---|---|
void |
addComponent(Object obj)
Add a component object to the injector.
|
LenskitConfigContext |
at(Annotation qualifier,
Class<?> type) |
LenskitConfigContext |
at(Annotation qualifier,
Class<?> type,
groovy.lang.Closure<?> block)
Enclose a block of configuration in a context.
|
LenskitConfigContext |
at(Class<?> type) |
LenskitConfigContext |
at(Class<?> type,
groovy.lang.Closure<?> block)
Configure inside an anchored context using a block.
|
LenskitConfigContext |
at(Class<? extends Annotation> qualifier,
Class<?> type) |
LenskitConfigContext |
at(Class<? extends Annotation> qualifier,
Class<?> type,
groovy.lang.Closure<?> block)
Enclose a block of configuration in a context.
|
<T> LenskitBinding<T> |
bind(Class<? extends Annotation> qual,
Class<T> type) |
<T> LenskitBinding<T> |
bind(Class<T> type) |
<T> LenskitBinding<T> |
bindAny(Class<T> type) |
PreferenceDomain |
domain(Map<String,Object> args)
Make and bind a preference domain.
|
LenskitConfigContext |
getContext()
Get the LensKit context.
|
void |
include(groovy.lang.Closure<?> cl)
Use a closure as additional configuration
|
void |
include(File file)
Include another configuration file.
|
void |
include(Module mod)
Include a module in this configuration.
|
void |
include(String file)
Include another configuration file.
|
LenskitConfigContext |
matching(ContextPattern pattern) |
Context |
matching(ContextPattern pattern,
groovy.lang.Closure<?> block) |
PreferenceDomain |
prefDomain(Map<String,Object> args)
Make a preference domain.
|
Binding |
set(Class<? extends Annotation> param)
Start a binding that sets a parameter.
|
LenskitConfigContext |
within(Annotation qualifier,
Class<?> type) |
LenskitConfigContext |
within(Annotation qualifier,
Class<?> type,
groovy.lang.Closure<?> block)
Enclose a block of configuration in a context.
|
LenskitConfigContext |
within(Class<?> type) |
LenskitConfigContext |
within(Class<?> type,
groovy.lang.Closure<?> block)
Enclose a block of configuration in a context.
|
LenskitConfigContext |
within(Class<? extends Annotation> qualifier,
Class<?> type) |
LenskitConfigContext |
within(Class<? extends Annotation> qualifier,
Class<?> type,
groovy.lang.Closure<?> block)
Enclose a block of configuration in a context.
|
addComponent, in, in, in, wrapContext
public LenskitConfigContext getContext()
public void include(groovy.lang.Closure<?> cl)
cl
- A closure that is run on this context to do additional configuration.public void include(File file) throws IOException, RecommenderConfigurationException
file
- The configuration file.IOException
- if an error is thrown loading the script.RecommenderConfigurationException
- if there is an error running the script.UnsupportedOperationException
- if the current context does not support loading.public void include(String file) throws IOException, RecommenderConfigurationException
file
- The configuration file.IOException
RecommenderConfigurationException
include(File)
public void include(Module mod)
mod
- The module to include.public <T> LenskitBinding<T> bind(Class<T> type)
LenskitConfigContext.bind(Class)
public <T> LenskitBinding<T> bind(Class<? extends Annotation> qual, Class<T> type)
bind
in interface Context
bind
in interface LenskitConfigContext
bind
in class AbstractConfigContext
LenskitConfigContext.bind(Class, Class)
public <T> LenskitBinding<T> bindAny(Class<T> type)
bindAny
in interface Context
bindAny
in interface LenskitConfigContext
bindAny
in class AbstractConfigContext
LenskitConfigContext.bindAny(Class)
public Binding set(@Nonnull Class<? extends Annotation> param)
LenskitConfigContext
Parameter
annotation.set
in interface LenskitConfigContext
set
in class AbstractConfigContext
param
- The parameter to set.LenskitConfigContext.set(Class)
public void addComponent(@Nonnull Object obj)
LenskitConfigContext
this.bind(obj.getClass()).to(obj);
It has the result of making obj
available satisfy dependencies on its class or,
via supertype binding generation, any of its supertypes. Explicit bindings for those
supertypes will override this binding.
addComponent
in interface LenskitConfigContext
addComponent
in class AbstractConfigContext
obj
- The object to register.public LenskitConfigContext within(Class<?> type)
LenskitConfigContext.within(Class)
public LenskitConfigContext within(Class<?> type, groovy.lang.Closure<?> block)
type
- The type to match for the context.block
- The configuration block.LenskitConfigContext.within(Class)
public LenskitConfigContext within(@Nullable Class<? extends Annotation> qualifier, Class<?> type)
public LenskitConfigContext within(@Nullable Class<? extends Annotation> qualifier, Class<?> type, groovy.lang.Closure<?> block)
qualifier
- The qualifier.type
- The type to match for the context.block
- The configuration block.LenskitConfigContext.within(Class, Class)
,
within(Class, Closure)
public LenskitConfigContext within(@Nullable Annotation qualifier, Class<?> type)
public LenskitConfigContext within(@Nullable Annotation qualifier, Class<?> type, groovy.lang.Closure<?> block)
qualifier
- The qualifier.type
- The type to match for the context.block
- The configuration block.LenskitConfigContext.within(Annotation, Class)
,
within(Class, Closure)
public LenskitConfigContext matching(ContextPattern pattern)
public Context matching(ContextPattern pattern, groovy.lang.Closure<?> block)
public LenskitConfigContext at(Class<?> type)
LenskitConfigContext.at(Class)
public LenskitConfigContext at(Class<?> type, groovy.lang.Closure<?> block)
type
- The type.block
- The configuration block.within(Class, Closure)
public LenskitConfigContext at(@Nullable Class<? extends Annotation> qualifier, Class<?> type)
LenskitConfigContext.at(Class, Class)
public LenskitConfigContext at(@Nullable Class<? extends Annotation> qualifier, Class<?> type, groovy.lang.Closure<?> block)
qualifier
- The qualifier.type
- The type to match for the context.block
- The configuration block.LenskitConfigContext.at(Class, Class)
,
at(Class, Closure)
public LenskitConfigContext at(@Nullable Annotation qualifier, Class<?> type)
public LenskitConfigContext at(@Nullable Annotation qualifier, Class<?> type, groovy.lang.Closure<?> block)
qualifier
- The qualifier.type
- The type to match for the context.block
- The configuration block.LenskitConfigContext.at(Annotation, Class)
,
at(Class, Closure)
public PreferenceDomain domain(Map<String,Object> args)
domain minimum: 1, maximum: 5
is equivalent to:
bind PreferenceDomain to prefDomain(minimum: 1, maximum: 5)
args
- The arguments.prefDomain(java.util.Map)
public PreferenceDomain prefDomain(Map<String,Object> args)
args
- The arguments.PreferenceDomain