public class OD extends Object
See package doc.
This class (OD
) is a namespace containing some interfaces and static methods.
Modifier and Type | Class and Description |
---|---|
static interface |
OD.Predicate<T>
Similar to Predicate
in Java 8.
|
static interface |
OD.Supplier<T>
Similar to Supplier
in Java 8.
|
static class |
OD.NotFoundException
Binding is not found for (type,tags).
|
static interface |
OD.Binding
Binding of (type,tags)->supplier.
|
static class |
OD.Local
Thread-local bindings.
|
static class |
OD.BindingBuilder<T>
Builder for creating bindings.
|
Static Methods | |
---|---|
<T> T |
get(Class<T> type,
Object... tags)
Lookup an object by (type,tags).
|
<T> T |
get(ClassType<T> type,
Object... tags)
Lookup an object by (type,tags).
|
<T> OD.BindingBuilder<T> |
bind(Class<T> clazz)
To add a global binding.
|
<T> OD.BindingBuilder<T> |
bind(ClassType<T> type)
To add a global binding.
|
void |
bind(OD.Binding binding)
Add the binding to the global binding list.
|
public static <T> T get(Class<T> type, Object... tags) throws OD.NotFoundException
This method is equivalent to get(ClassType, Object...)
by wrapping the `Class` as `ClassType`; see ClassType.of(Class)
.
OD.NotFoundException
public static <T> T get(ClassType<T> type, Object... tags) throws OD.NotFoundException
The local binding list is searched before the global binding list.
If a binding is found to match (type,tags)
,
the supplier is invoked to return a `T` value.
Otherwise, `NotFoundException` is thrown.
OD.NotFoundException
- if binding is not found for (type,tags)get(Class, Object...)
public static <T> OD.BindingBuilder<T> bind(Class<T> clazz)
This method is equivalent to bind(ClassType)
by wrapping the `Class` as `ClassType`; see ClassType.of(Class)
.
Example usage:
OD.bind(Foo.class).to(foo);
public static <T> OD.BindingBuilder<T> bind(ClassType<T> type)
This method return a builder; when the builder finishes, a binding is created and added to the global binding list.
Example usage:
OD.bind( ClassType.of(Foo.class) ).to(foo);
bind(Class)
,
ClassType
public static void bind(OD.Binding binding)