|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.common.reflect.ImmutableTypeToInstanceMap.Builder<B>
@Beta public static final class ImmutableTypeToInstanceMap.Builder<B>
A builder for creating immutable type-to-instance maps. Example:
static final ImmutableTypeToInstanceMap<Handler<?>> HANDLERS =
ImmutableTypeToInstanceMap.<Handler<?>>builder()
.put(new TypeToken<Handler<Foo>>() {}, new FooHandler())
.put(new TypeToken<Handler<Bar>>() {}, new SubBarHandler())
.build();
After invoking build() it is still possible to add more entries
and build again. Thus each map generated by this builder will be a superset
of any map generated before it.
| Method Summary | ||
|---|---|---|
ImmutableTypeToInstanceMap<B> |
build()
Returns a new immutable type-to-instance map containing the entries provided to this builder. |
|
|
put(Class<T> key,
T value)
Associates key with value in the built map. |
|
|
put(TypeToken<T> key,
T value)
Associates key with value in the built map. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public <T extends B> ImmutableTypeToInstanceMap.Builder<B> put(Class<T> key,
T value)
key with value in the built map. Duplicate
keys are not allowed, and will cause build() to fail.
public <T extends B> ImmutableTypeToInstanceMap.Builder<B> put(TypeToken<T> key,
T value)
key with value in the built map. Duplicate
keys are not allowed, and will cause build() to fail.
public ImmutableTypeToInstanceMap<B> build()
IllegalArgumentException - if duplicate keys were added
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||