Package jsonvalues

Interface MutableMap


  • public interface MutableMap
    Represents a mutable data structure where pairs of a JsObj are stored. Each mutable Json factory MutableJsons has an implementation of this interface, that can be defined using the method MutableJsons.withMap(Class). The default mutable implementation that Jsons.mutable uses is the Java HashMap
    • Method Detail

      • copy

        MutableMap copy()
        creates and returns a copy of this map
        Returns:
        a new instance
      • remove

        void remove​(String key)
        removes the key associated with this map. It will be called by the library only if the key exists
        Parameters:
        key - the given key
      • update

        void update​(String key,
                    JsElem je)
        updates the element associated with the key with a new element. It will be called by the library only if the key exists,
        Parameters:
        key - the given key
        je - the new element
      • contains

        boolean contains​(String key)
        returns true if the map contains the key
        Parameters:
        key - the given key
        Returns:
        true if the map contains the key, false if not
      • keys

        Set<String> keys()
        returns the keys of this map
        Returns:
        set of keys
      • get

        JsElem get​(String key)
        return the element associated with the key. It will be called by the library only if the key exists, so an error can be thrown if it doesn't
        Parameters:
        key - the given key
        Returns:
        the element associated with the key or JsNothing if it doesn't exist
      • getOptional

        Optional<JsElem> getOptional​(String key)
        return the element associated with the key wrapped into an optional. It's called by the library without checking the existence of the key.
        Parameters:
        key - the given key
        Returns:
        the element associated with the key or Optional.empty() if it doesn't exist
      • head

        Map.Entry<String,​JsElem> head()
        an entry of this map. A map is unordered, so any element could be the head. It's only called by the library if the map is not empty.
        Returns:
        an entry of this map
      • isEmpty

        boolean isEmpty()
        returns true if this map is empty
        Returns:
        true if empty, false otherwise
      • size

        int size()
        returns the size of the map
        Returns:
        the size of the map
      • tail

        M tail​(String head)
        the tail of the map given a head. It's only called by the library if the map is not empty.
        Parameters:
        head - the element returned by head()
        Returns:
        the tail of the map given a head