Silk DI 0.6


se.jbee.inject.bootstrap
Class Macros

Object
  extended by se.jbee.inject.bootstrap.Macros

public final class Macros
extends Object

A immutable collection of Macros each bound to a specific type handled.

Author:
Jan Bernitt (jan@jbee.se)

Field Summary
static Macro<Parameter<?>[]> ARRAY
           
static Macro<Configuring<?>> CONFIGURE
           
static Macro<Constructible<?>> CONSTRUCT
           
static Macros DEFAULT
           
static Macros EMPTY
           
static Macro<Binding<?>> EXPAND
           
static Macro<Class<?>> FORWARD
           
static Module NO_OP
           
static Macro<Producible<?>> PRODUCE
           
static Macro<Instance<?>> SUBSTITUTE
           
 
Method Summary
<T,V> Module
expand(Binding<T> binding, V value)
          A generic version of Macro.expand(Binding, Object) that uses the matching predefined Macro for the actual type of the value and expands it.
(package private) static
<T> Module
implicitBindToConstructor(Binding<?> binding, Instance<T> instance)
           
static Module macro(Module... steps)
           
static Module macro(Module mandatory, Module optional)
           
<T> Macros
use(Class<T> type, Macro<? extends T> macro)
          Uses the given Macro for the given exact (no super-types!)
<T> Macros
use(Macro<T> macro)
          Uses the given Macro and derives the use(Class, Macro) type from its declaration.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY

public static final Macros EMPTY

EXPAND

public static final Macro<Binding<?>> EXPAND

CONSTRUCT

public static final Macro<Constructible<?>> CONSTRUCT

SUBSTITUTE

public static final Macro<Instance<?>> SUBSTITUTE

PRODUCE

public static final Macro<Producible<?>> PRODUCE

CONFIGURE

public static final Macro<Configuring<?>> CONFIGURE

FORWARD

public static final Macro<Class<?>> FORWARD

ARRAY

public static final Macro<Parameter<?>[]> ARRAY

NO_OP

public static final Module NO_OP

DEFAULT

public static final Macros DEFAULT
Method Detail

macro

public static Module macro(Module mandatory,
                           Module optional)

macro

public static Module macro(Module... steps)

use

public <T> Macros use(Macro<T> macro)
Uses the given Macro and derives the use(Class, Macro) type from its declaration. This is a utility method that can be used as long as the Macro implementation is not generic.

Parameters:
macro - No generic macro class (e.g. decorators)
Returns:
A set of Macros containing the given one for the type derived from its type declaration.

use

public <T> Macros use(Class<T> type,
                      Macro<? extends T> macro)
Uses the given Macro for the given exact (no super-types!) type of values.

Parameters:
type - The type of value that should be passed to the Macro as value
macro - The Macro expanding the type of value
Returns:
A set of Macros containing the given one

expand

public <T,V> Module expand(Binding<T> binding,
                           V value)
A generic version of Macro.expand(Binding, Object) that uses the matching predefined Macro for the actual type of the value and expands it.

Parameters:
binding - The incoplete binding to expand
value - Non-null value to expand via matching Macro
Returns:
Module results from Macro.expand(Binding, Object)
Throws:
DIRuntimeException - In case no Macro had been declared for the type of value argument

implicitBindToConstructor

static <T> Module implicitBindToConstructor(Binding<?> binding,
                                            Instance<T> instance)

Silk DI 0.6