Class ImmutableClassToInstanceMap<B>

    • Method Detail

      • of

        public static <B> ImmutableClassToInstanceMap<B> of()
        Returns an empty ImmutableClassToInstanceMap.

        Performance note: the instance returned is a singleton.

        Type Parameters:
        B - the Map's key type
        Returns:
        an empty Map
        Since:
        19.0
      • of

        public static <B,​T extends B> ImmutableClassToInstanceMap<B> of​(Class<T> type,
                                                                              T value)
        Returns an ImmutableClassToInstanceMap containing a single entry.
        Type Parameters:
        B - the Map's key type
        T - the Map's value type
        Parameters:
        type - the mapping's key
        value - the mapping's value
        Returns:
        a Map containing the specified mapping
        Since:
        19.0
      • copyOf

        public static <B,​S extends B> ImmutableClassToInstanceMap<B> copyOf​(Map<? extends Class<? extends S>,​? extends S> map)
        Returns an immutable map containing the same entries as map. If map somehow contains entries with duplicate keys (for example, if it is a SortedMap whose comparator is not consistent with equals), the results of this method are undefined.

        Note: Despite what the method name suggests, if map is an ImmutableClassToInstanceMap, no copy will actually be performed.

        Type Parameters:
        B - the Map's key type
        S - the Map's value type
        Parameters:
        map - a Map from which entries are drawn, must be non-null
        Returns:
        a Map containing the entries of the given Map
        Throws:
        NullPointerException - if any key or value in map is null
        ClassCastException - if any value is not an instance of the type specified by its key
      • delegate

        protected Map<Class<? extends B>,​Bdelegate()
        Description copied from class: ForwardingObject
        Returns the backing delegate instance that methods are forwarded to. Abstract subclasses generally override this method with an abstract method that has a more specific return type, such as ForwardingSet.delegate(). Concrete subclasses override this method to supply the instance being decorated.
        Specified by:
        delegate in class ForwardingMap<Class<? extends B>,​B>
      • getInstance

        @CheckForNull
        public <T extends B> T getInstance​(Class<T> type)
        Description copied from interface: ClassToInstanceMap
        Returns the value the specified class is mapped to, or null if no entry for this class is present. This will only return a value that was bound to this specific class, not a value that may have been bound to a subtype.
        Specified by:
        getInstance in interface ClassToInstanceMap<B>