Class CompositeValueMap

  • All Implemented Interfaces:
    java.util.Map<java.lang.String,​java.lang.Object>, ValueMap

    @Deprecated
    public class CompositeValueMap
    extends java.lang.Object
    implements ValueMap
    Deprecated.
    Use ValueMapUtil.merge(ValueMap...) instead. Note that it does not support the parameter merge = false. However, this could easily be achieved with another decorator that restricts the set of allowed keys.
    An implementation of the ValueMap based on two ValueMaps: - One containing the properties - Another one containing the defaults to use in case the properties map does not contain the values. In case you would like to avoid duplicating properties on multiple resources, you can use a CompositeValueMap to get a concatenated map of properties.
    Since:
    2.3 (Sling API Bundle 2.5.0)
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Field Summary

      • Fields inherited from interface org.apache.sling.api.resource.ValueMap

        EMPTY
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void clear()
      Deprecated.
      boolean containsKey​(java.lang.Object key)
      Deprecated.
      boolean containsValue​(java.lang.Object value)
      Deprecated.
      java.util.Set<java.util.Map.Entry<java.lang.String,​java.lang.Object>> entrySet()
      Deprecated.
      <T> T get​(@NotNull java.lang.String name, @NotNull java.lang.Class<T> type)
      Deprecated.
      Get a named property and convert it into the given type.
      <T> T get​(@NotNull java.lang.String name, T defaultValue)
      Deprecated.
      Get a named property and convert it into the given type.
      java.lang.Object get​(java.lang.Object key)
      Deprecated.
      boolean isEmpty()
      Deprecated.
      java.util.Set<java.lang.String> keySet()
      Deprecated.
      java.lang.Object put​(java.lang.String aKey, java.lang.Object value)
      Deprecated.
      void putAll​(java.util.Map<? extends java.lang.String,​?> properties)
      Deprecated.
      java.lang.Object remove​(java.lang.Object key)
      Deprecated.
      int size()
      Deprecated.
      java.util.Collection<java.lang.Object> values()
      Deprecated.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Constructor Detail

      • CompositeValueMap

        public CompositeValueMap​(ValueMap properties,
                                 ValueMap defaults)
        Deprecated.
        Constructor
        Parameters:
        properties - The ValueMap to read from
        defaults - The default ValueMap to use as fallback
      • CompositeValueMap

        public CompositeValueMap​(ValueMap properties,
                                 ValueMap defaults,
                                 boolean merge)
        Deprecated.
        Constructor
        Parameters:
        properties - The ValueMap to read from
        defaults - The default ValueMap to use as fallback
        merge - Merge flag - If true, getting a key would return the current property map's value (if available), even if the corresponding default does not exist. - If false, getting a key would return null if the corresponding default does not exist
    • Method Detail

      • get

        @Nullable
        public <T> T get​(@NotNull
                         @NotNull java.lang.String name,
                         @NotNull
                         @NotNull java.lang.Class<T> type)
        Deprecated.
        Get a named property and convert it into the given type. This method does not support conversion into a primitive type or an array of a primitive type. It should return null in this case.
        Specified by:
        get in interface ValueMap
        Type Parameters:
        T - The class of the type
        Parameters:
        name - The name of the property
        type - The class of the type
        Returns:
        Return named value converted to type T or null if non existing or can't be converted.
      • get

        @NotNull
        public <T> T get​(@NotNull
                         @NotNull java.lang.String name,
                         @NotNull
                         T defaultValue)
        Deprecated.
        Get a named property and convert it into the given type. This method does not support conversion into a primitive type or an array of a primitive type. It should return the default value in this case.

        Implementation hint: In the past it was allowed to call this with a 2nd parameter being null. Therefore all implementations should internally call Map.get(Object) when the 2nd parameter has value null.
        Specified by:
        get in interface ValueMap
        Type Parameters:
        T - The expected type
        Parameters:
        name - The name of the property
        defaultValue - The default value to use if the named property does not exist or cannot be converted to the requested type. The default value is also used to define the type to convert the value to. Must not be null. If you want to return null by default rather rely on ValueMap.get(String, Class).
        Returns:
        Return named value converted to type T or the default value if non existing or can't be converted.
      • size

        public int size()
        Deprecated.
        Specified by:
        size in interface java.util.Map<java.lang.String,​java.lang.Object>
      • isEmpty

        public boolean isEmpty()
        Deprecated.
        Specified by:
        isEmpty in interface java.util.Map<java.lang.String,​java.lang.Object>
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Deprecated.
        Specified by:
        containsKey in interface java.util.Map<java.lang.String,​java.lang.Object>
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Deprecated.
        Specified by:
        containsValue in interface java.util.Map<java.lang.String,​java.lang.Object>
      • get

        public java.lang.Object get​(java.lang.Object key)
        Deprecated.
        Specified by:
        get in interface java.util.Map<java.lang.String,​java.lang.Object>
      • put

        public java.lang.Object put​(java.lang.String aKey,
                                    java.lang.Object value)
        Deprecated.
        Specified by:
        put in interface java.util.Map<java.lang.String,​java.lang.Object>
      • remove

        public java.lang.Object remove​(java.lang.Object key)
        Deprecated.
        Specified by:
        remove in interface java.util.Map<java.lang.String,​java.lang.Object>
      • putAll

        public void putAll​(java.util.Map<? extends java.lang.String,​?> properties)
        Deprecated.
        Specified by:
        putAll in interface java.util.Map<java.lang.String,​java.lang.Object>
      • clear

        public void clear()
        Deprecated.
        Specified by:
        clear in interface java.util.Map<java.lang.String,​java.lang.Object>
      • keySet

        public java.util.Set<java.lang.String> keySet()
        Deprecated.
        Specified by:
        keySet in interface java.util.Map<java.lang.String,​java.lang.Object>
      • values

        public java.util.Collection<java.lang.Object> values()
        Deprecated.
        Specified by:
        values in interface java.util.Map<java.lang.String,​java.lang.Object>
      • entrySet

        public java.util.Set<java.util.Map.Entry<java.lang.String,​java.lang.Object>> entrySet()
        Deprecated.
        Specified by:
        entrySet in interface java.util.Map<java.lang.String,​java.lang.Object>