javadoc.com.google.common.collect.ImmutableClassToInstanceMap.Builder.html Maven / Gradle / Ivy
The newest version!
ImmutableClassToInstanceMap.Builder (Guava: Google Core Libraries for Java 11.0.1 API)
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
com.google.common.collect
Class ImmutableClassToInstanceMap.Builder<B>
java.lang.Object
com.google.common.collect.ImmutableClassToInstanceMap.Builder<B>
- Enclosing class:
- ImmutableClassToInstanceMap<B>
public static final class ImmutableClassToInstanceMap.Builder<B>
- extends Object
A builder for creating immutable class-to-instance maps. Example:
static final ImmutableClassToInstanceMap<Handler> HANDLERS =
new ImmutableClassToInstanceMap.Builder<Handler>()
.put(FooHandler.class, new FooHandler())
.put(BarHandler.class, new SubBarHandler())
.put(Handler.class, new QuuxHandler())
.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.
- Since:
- 2.0 (imported from Google Collections Library)
Constructor Summary | |
---|---|
ImmutableClassToInstanceMap.Builder()
|
Method Summary | ||
---|---|---|
ImmutableClassToInstanceMap<B> |
build()
Returns a new immutable class-to-instance map containing the entries provided to this builder. |
|
|
put(Class<T> key,
T value)
Associates key with value in the built map. |
|
|
putAll(Map<? extends Class<? extends T>,? extends T> map)
Associates all of map's keys and values in the built map. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
ImmutableClassToInstanceMap.Builder
public ImmutableClassToInstanceMap.Builder()
Method Detail |
---|
put
public <T extends B> ImmutableClassToInstanceMap.Builder<B> put(Class<T> key, T value)
- Associates
key
withvalue
in the built map. Duplicate keys are not allowed, and will causebuild()
to fail.
putAll
public <T extends B> ImmutableClassToInstanceMap.Builder<B> putAll(Map<? extends Class<? extends T>,? extends T> map)
- Associates all of
map's
keys and values in the built map. Duplicate keys are not allowed, and will causebuild()
to fail.- Throws:
NullPointerException
- if any key or value inmap
is nullClassCastException
- if any value is not an instance of the type specified by its key
build
public ImmutableClassToInstanceMap<B> build()
- Returns a new immutable class-to-instance map containing the entries
provided to this builder.
- Throws:
IllegalArgumentException
- if duplicate keys were added
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2010-2012. All Rights Reserved.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy