Class ImmutableOffsetMapTemplate<K>

    • Method Detail

      • ordered

        public static <K> @NonNull ImmutableOffsetMapTemplate<K> ordered​(Collection<K> keys)
        Create a template which produces Maps with specified keys, with iteration order matching the iteration order of keys. keySet() will return these keys in exactly the same order. The resulting map will retain insertion order through UnmodifiableMapPhase.toModifiableMap() transformations.
        Type Parameters:
        K - the type of keys maintained by resulting template
        Parameters:
        keys - Keys in requested iteration order.
        Returns:
        A template object.
        Throws:
        NullPointerException - if keys or any of its elements is null
        IllegalArgumentException - if keys is does not have at least two keys
      • unordered

        public static <K> @NonNull ImmutableOffsetMapTemplate<K> unordered​(Collection<K> keys)
        Create a template which produces Maps with specified keys, with unconstrained iteration order. Produced maps will have the iteration order matching the order returned by keySet(). The resulting map will NOT retain ordering through UnmodifiableMapPhase.toModifiableMap() transformations.
        Type Parameters:
        K - the type of keys maintained by resulting template
        Parameters:
        keys - Keys in any iteration order.
        Returns:
        A template object.
        Throws:
        NullPointerException - if keys or any of its elements is null
        IllegalArgumentException - if keys is does not have at least two keys
      • keySet

        public final Set<K> keySet()
        Description copied from class: ImmutableMapTemplate
        Returns the set of keys expected by this template, in the iteration order Maps resulting from instantiation will have.
        Specified by:
        keySet in class ImmutableMapTemplate<K>
        Returns:
        This template's key set
        See Also:
        Map.keySet()
      • instantiateTransformed

        public final <T,​V> @NonNull ImmutableOffsetMap<K,​V> instantiateTransformed​(Map<K,​T> fromMap,
                                                                                               BiFunction<K,​T,​V> valueTransformer)
        Description copied from class: ImmutableMapTemplate
        Instantiate an immutable map by applying specified transformer to values of fromMap.
        Specified by:
        instantiateTransformed in class ImmutableMapTemplate<K>
        Type Parameters:
        T - the type of input values
        V - the type of mapped values
        Parameters:
        fromMap - Input map
        valueTransformer - Transformation to apply to values
        Returns:
        An immutable map