Interface MapAccessorWithDefaultValue

All Superinterfaces:
MapAccessor
All Known Subinterfaces:
InternalValue, Record, Value
All Known Implementing Classes:
BooleanValue, BytesValue, DateTimeValue, DateValue, DurationValue, EntityValueAdapter, FloatValue, IntegerValue, InternalMapAccessorWithDefaultValue, ListValue, LocalDateTimeValue, LocalTimeValue, MapValue, NodeValue, NullValue, NumberValueAdapter, ObjectValueAdapter, PathValue, PointValue, RelationshipValue, StringValue, TimeValue, UnsupportedDateTimeValue, ValueAdapter

public interface MapAccessorWithDefaultValue extends MapAccessor
Provides methods to access the value of an underlying unordered map by key. When calling the methods, a user need to provide a default value, which will be given back if no match found by the key provided. The default value also servers the purpose of specifying the return type of the value found in map by key. If the type of the value found A differs from the type of the default value B, a cast from A to B would happen automatically. Note: Error might arise if the cast from A to B is not possible.
  • Method Details

    • get

      Value get(String key, Value defaultValue)
      Retrieve the value with the given key. If no value found by the key, then the default value provided would be returned.
      Parameters:
      key - the key of the value
      defaultValue - the default value that would be returned if no value found by the key in the map
      Returns:
      the value found by the key or the default value if no such key exists
    • get

      Object get(String key, Object defaultValue)
      Retrieve the object with the given key. If no object found by the key, then the default object provided would be returned.
      Parameters:
      key - the key of the object
      defaultValue - the default object that would be returned if no object found by the key in the map
      Returns:
      the object found by the key or the default object if no such key exists
    • get

      Number get(String key, Number defaultValue)
      Retrieve the number with the given key. If no number found by the key, then the default number provided would be returned.
      Parameters:
      key - the key of the number
      defaultValue - the default number that would be returned if no number found by the key in the map
      Returns:
      the number found by the key or the default number if no such key exists
    • get

      Entity get(String key, Entity defaultValue)
      Retrieve the entity with the given key. If no entity found by the key, then the default entity provided would be returned.
      Parameters:
      key - the key of the entity
      defaultValue - the default entity that would be returned if no entity found by the key in the map
      Returns:
      the entity found by the key or the default entity if no such key exists
    • get

      Node get(String key, Node defaultValue)
      Retrieve the node with the given key. If no node found by the key, then the default node provided would be returned.
      Parameters:
      key - the key of the node
      defaultValue - the default node that would be returned if no node found by the key in the map
      Returns:
      the node found by the key or the default node if no such key exists
    • get

      Path get(String key, Path defaultValue)
      Retrieve the path with the given key. If no path found by the key, then the default path provided would be returned.
      Parameters:
      key - the key of the property
      defaultValue - the default path that would be returned if no path found by the key in the map
      Returns:
      the path found by the key or the default path if no such key exists
    • get

      Relationship get(String key, Relationship defaultValue)
      Retrieve the value with the given key. If no value found by the key, then the default value provided would be returned.
      Parameters:
      key - the key of the property
      defaultValue - the default value that would be returned if no value found by the key in the map
      Returns:
      the value found by the key or the default value if no such key exists
    • get

      List<Object> get(String key, List<Object> defaultValue)
      Retrieve the list of objects with the given key. If no value found by the key, then the default value provided would be returned.
      Parameters:
      key - the key of the value
      defaultValue - the default value that would be returned if no value found by the key in the map
      Returns:
      the list of objects found by the key or the default value if no such key exists
    • get

      <T> List<T> get(String key, List<T> defaultValue, Function<Value,T> mapFunc)
      Retrieve the list with the given key. If no value found by the key, then the default list provided would be returned.
      Type Parameters:
      T - the type of the elements in the returned list
      Parameters:
      key - the key of the value
      defaultValue - the default value that would be returned if no value found by the key in the map
      mapFunc - the map function that defines how to map each element of the list from Value to T
      Returns:
      the converted list found by the key or the default list if no such key exists
    • get

      Map<String,Object> get(String key, Map<String,Object> defaultValue)
      Retrieve the map with the given key. If no value found by the key, then the default value provided would be returned.
      Parameters:
      key - the key of the property
      defaultValue - the default value that would be returned if no value found by the key in the map
      Returns:
      the map found by the key or the default value if no such key exists
    • get

      <T> Map<String,T> get(String key, Map<String,T> defaultValue, Function<Value,T> mapFunc)
      Retrieve the map with the given key. If no value found by the key, then the default map provided would be returned.
      Type Parameters:
      T - the type of the values in the returned map
      Parameters:
      key - the key of the value
      defaultValue - the default value that would be returned if no value found by the key in the map
      mapFunc - the map function that defines how to map each value in map from Value to T
      Returns:
      the converted map found by the key or the default map if no such key exists.
    • get

      int get(String key, int defaultValue)
      Retrieve the java integer with the given key. If no integer found by the key, then the default integer provided would be returned.
      Parameters:
      key - the key of the property
      defaultValue - the default integer that would be returned if no integer found by the key in the map
      Returns:
      the integer found by the key or the default integer if no such key exists
    • get

      long get(String key, long defaultValue)
      Retrieve the java long number with the given key. If no value found by the key, then the default value provided would be returned.
      Parameters:
      key - the key of the property
      defaultValue - the default value that would be returned if no value found by the key in the map
      Returns:
      the java long number found by the key or the default value if no such key exists
    • get

      boolean get(String key, boolean defaultValue)
      Retrieve the java boolean with the given key. If no value found by the key, then the default value provided would be returned.
      Parameters:
      key - the key of the property
      defaultValue - the default value that would be returned if no value found by the key in the map
      Returns:
      the java boolean found by the key or the default value if no such key exists
    • get

      String get(String key, String defaultValue)
      Retrieve the java string with the given key. If no string found by the key, then the default string provided would be returned.
      Parameters:
      key - the key of the property
      defaultValue - the default string that would be returned if no string found by the key in the map
      Returns:
      the string found by the key or the default string if no such key exists
    • get

      float get(String key, float defaultValue)
      Retrieve the java float number with the given key. If no value found by the key, then the default value provided would be returned.
      Parameters:
      key - the key of the property
      defaultValue - the default value that would be returned if no value found by the key in the map
      Returns:
      the java float number found by the key or the default value if no such key exists
    • get

      double get(String key, double defaultValue)
      Retrieve the java double number with the given key. If no value found by the key, then the default value provided would be returned.
      Parameters:
      key - the key of the property
      defaultValue - the default value that would be returned if no value found by the key in the map
      Returns:
      the java double number found by the key or the default value if no such key exists