* Copyright (C) 2009 The Guava Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
. See also
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();
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.
valuein the built map. Duplicate keys are not allowed, and will cause
java.lang.IllegalArgumentExceptionif duplicate keys were added
mapsomehow contains entries with duplicate keys (for example, if it is a
SortedMapwhose comparator is not consistent with equals), the results of this method are undefined.
Note: Despite what the method name suggests, if
ImmutableClassToInstanceMap, no copy will actually be performed.
// Eclipse won't compile if we cast to the parameterized type.