public class BindingDSL extends AbstractConfigContext
Groovy DSL definition for configuring LensKit recommenders. This class is the base class of configuration scripts and the delegate against which configuration blocks are run.
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(java.lang.Object obj)
Add a component object to the injector.
|
LenskitConfigContext |
at(java.lang.annotation.Annotation qualifier,
java.lang.Class<?> type) |
LenskitConfigContext |
at(java.lang.annotation.Annotation qualifier,
java.lang.Class<?> type,
groovy.lang.Closure<?> block)
Enclose a block of configuration in a context.
|
LenskitConfigContext |
at(java.lang.Class<?> type) |
LenskitConfigContext |
at(java.lang.Class<?> type,
groovy.lang.Closure<?> block)
Configure inside an anchored context using a block.
|
LenskitConfigContext |
at(java.lang.Class<? extends java.lang.annotation.Annotation> qualifier,
java.lang.Class<?> type) |
LenskitConfigContext |
at(java.lang.Class<? extends java.lang.annotation.Annotation> qualifier,
java.lang.Class<?> type,
groovy.lang.Closure<?> block)
Enclose a block of configuration in a context.
|
<T> LenskitBinding<T> |
bind(java.lang.Class<? extends java.lang.annotation.Annotation> qual,
java.lang.Class<T> type) |
<T> LenskitBinding<T> |
bind(java.lang.Class<T> type) |
<T> LenskitBinding<T> |
bindAny(java.lang.Class<T> type) |
PreferenceDomain |
domain(java.util.Map<java.lang.String,java.lang.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(Module mod)
Include a module in this configuration.
|
void |
include(java.lang.String file)
Include another configuration file.
|
void |
include(java.net.URI uri)
Include another configuration file.
|
LenskitConfigContext |
matching(ContextPattern pattern) |
Context |
matching(ContextPattern pattern,
groovy.lang.Closure<?> block) |
PreferenceDomain |
prefDomain(java.util.Map<java.lang.String,java.lang.Object> args)
Make a preference domain.
|
Binding |
set(java.lang.Class<? extends java.lang.annotation.Annotation> param)
Start a binding that sets a parameter.
|
LenskitConfigContext |
within(java.lang.annotation.Annotation qualifier,
java.lang.Class<?> type) |
LenskitConfigContext |
within(java.lang.annotation.Annotation qualifier,
java.lang.Class<?> type,
groovy.lang.Closure<?> block)
Enclose a block of configuration in a context.
|
LenskitConfigContext |
within(java.lang.Class<?> type) |
LenskitConfigContext |
within(java.lang.Class<?> type,
groovy.lang.Closure<?> block)
Enclose a block of configuration in a context.
|
LenskitConfigContext |
within(java.lang.Class<? extends java.lang.annotation.Annotation> qualifier,
java.lang.Class<?> type) |
LenskitConfigContext |
within(java.lang.Class<? extends java.lang.annotation.Annotation> qualifier,
java.lang.Class<?> type,
groovy.lang.Closure<?> block)
Enclose a block of configuration in a context.
|
addComponent, in, in, in, wrapContext
public LenskitConfigContext getContext()
Get the LensKit context.
public void include(groovy.lang.Closure<?> cl)
Use a closure as additional configuration
cl
- A closure that is run on this context to do additional configuration.public void include(java.net.URI uri) throws java.io.IOException, RecommenderConfigurationException
Include another configuration file.
uri
- The URI of the configuration file.java.io.IOException
- if an error is thrown loading the script.RecommenderConfigurationException
- if there is an error running the script.java.lang.UnsupportedOperationException
- if the current context does not support loading.public void include(java.lang.String file) throws java.io.IOException, RecommenderConfigurationException
Include another configuration file.
file
- The configuration file name or URI.java.io.IOException
RecommenderConfigurationException
include(URI)
public void include(Module mod)
Include a module in this configuration.
mod
- The module to include.public <T> LenskitBinding<T> bind(java.lang.Class<T> type)
LenskitConfigContext.bind(Class)
public <T> LenskitBinding<T> bind(java.lang.Class<? extends java.lang.annotation.Annotation> qual, java.lang.Class<T> type)
bind
in interface Context
bind
in interface LenskitConfigContext
bind
in class AbstractConfigContext
LenskitConfigContext.bind(Class, Class)
public <T> LenskitBinding<T> bindAny(java.lang.Class<T> type)
bindAny
in interface Context
bindAny
in interface LenskitConfigContext
bindAny
in class AbstractConfigContext
LenskitConfigContext.bindAny(Class)
public Binding set(@Nonnull java.lang.Class<? extends java.lang.annotation.Annotation> param)
LenskitConfigContext
Start a binding that sets a parameter. Parameters are qualifiers that bear the Parameter
annotation.
set
in interface LenskitConfigContext
set
in class AbstractConfigContext
param
- The parameter to set.LenskitConfigContext.set(Class)
public void addComponent(@Nonnull java.lang.Object obj)
LenskitConfigContext
Add a component object to the injector. This is the equivalent of:
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(java.lang.Class<?> type)
LenskitConfigContext.within(Class)
public LenskitConfigContext within(java.lang.Class<?> type, groovy.lang.Closure<?> block)
Enclose a block of configuration in a context. The block is invoked with a delegate that adds bindings within the specified context.
type
- The type to match for the context.block
- The configuration block.LenskitConfigContext.within(Class)
public LenskitConfigContext within(@Nullable java.lang.Class<? extends java.lang.annotation.Annotation> qualifier, java.lang.Class<?> type)
public LenskitConfigContext within(@Nullable java.lang.Class<? extends java.lang.annotation.Annotation> qualifier, java.lang.Class<?> type, groovy.lang.Closure<?> block)
Enclose a block of configuration in a context.
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 java.lang.annotation.Annotation qualifier, java.lang.Class<?> type)
public LenskitConfigContext within(@Nullable java.lang.annotation.Annotation qualifier, java.lang.Class<?> type, groovy.lang.Closure<?> block)
Enclose a block of configuration in a context.
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(java.lang.Class<?> type)
LenskitConfigContext.at(Class)
public LenskitConfigContext at(java.lang.Class<?> type, groovy.lang.Closure<?> block)
Configure inside an anchored context using a block.
type
- The type.block
- The configuration block.within(Class, Closure)
public LenskitConfigContext at(@Nullable java.lang.Class<? extends java.lang.annotation.Annotation> qualifier, java.lang.Class<?> type)
LenskitConfigContext.at(Class, Class)
public LenskitConfigContext at(@Nullable java.lang.Class<? extends java.lang.annotation.Annotation> qualifier, java.lang.Class<?> type, groovy.lang.Closure<?> block)
Enclose a block of configuration in a context.
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 java.lang.annotation.Annotation qualifier, java.lang.Class<?> type)
public LenskitConfigContext at(@Nullable java.lang.annotation.Annotation qualifier, java.lang.Class<?> type, groovy.lang.Closure<?> block)
Enclose a block of configuration in a context.
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(java.util.Map<java.lang.String,java.lang.Object> args)
Make and bind a preference domain. With this method, this:
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(java.util.Map<java.lang.String,java.lang.Object> args)
Make a preference domain. This method takes three named arguments:
args
- The arguments.PreferenceDomain