Interface MapAccessor<T>

Type Parameters:
T - The value type.
All Superinterfaces:
Serializable
All Known Subinterfaces:
CompositeMapAccessor<T>, Key<T>, NonNullKey<T>, NonNullMapAccessor<T>, NullableKey<T>
All Known Implementing Classes:
AbstractKey, NonNullListKey, NonNullObjectKey, NullableObjectKey, SetValueMapAccessor, TransientKey

public interface MapAccessor<T> extends Serializable
A type safe accessor for maps.

Design pattern: Strategy

Author:
Werner Randelshofer
  • Field Details

  • Method Details

    • containsKey

      boolean containsKey(Map<Key<?>,Object> map)
      Whether the map contains all keys required by this map accessor.
      Parameters:
      map - a map
      Returns:
      true if map contains all keys required by this map accessor.
    • getName

      @NonNull String getName()
      Returns the name string.
      Returns:
      name string.
    • get

      @Nullable T get(@NonNull Map<? super Key<?>,Object> a)
      Gets the value of the attribute denoted by this accessor from a Map.
      Parameters:
      a - A Map.
      Returns:
      The value of the attribute.
    • get

      default @Nullable T get(@NonNull ReadOnlyMap<? super Key<?>,Object> a)
    • put

      @Nullable T put(@NonNull Map<? super Key<?>,Object> a, @Nullable T value)
      Puts the value of the attribute denoted by this accessor from a Map.
      Parameters:
      a - A map.
      value - The new value. Subclasses may require that the value is non-null.
      Returns:
      The old value.
    • put

      Puts the value of the attribute denoted by this accessor from a Map.
      Parameters:
      a - A map.
      value - The new value. Subclasses may require that the value is non-null.
      Returns:
      The updated map.
    • set

      default void set(@NonNull Map<? super Key<?>,Object> a, @Nullable T value)
      Sets the value of the attribute denoted by this accessor from a Map.
      Parameters:
      a - A map.
      value - The new value. Subclasses may require that the value is non-null.
    • remove

      @Nullable T remove(@NonNull Map<? super Key<?>,Object> a)
      Removes the value of the attribute denoted by this accessor from a Map.
      Parameters:
      a - A map.
      Returns:
      The old value.
    • remove

      Removes the value of the attribute denoted by this accessor from a Map.
      Parameters:
      a - A map.
      Returns:
      The old value.
    • getValueType

      @NonNull Type getValueType()
      Returns the value type of this map accessor.

      If the value type has type parameters, make sure to create it using TypeToken.

    • getRawValueType

      default @NonNull Class<T> getRawValueType()
      Returns the raw value type of this map accessor.
    • getDefaultValue

      @Nullable T getDefaultValue()
      Returns the default value of this map accessor.

      The default value of an attribute or property is the value used when that attribute or property is not specified.

      Returns:
      the default value
    • isTransient

      boolean isTransient()
      Whether the value needs to be made persistent.
      Returns:
      true if transient