Class MappingContext

java.lang.Object
com.helixframework.mapper.MappingContext

public final class MappingContext extends Object
Immutable mapping context passed to mapper operations.
  • Method Details

    • empty

      public static MappingContext empty()
      Returns an empty mapping context.
      Returns:
      the empty mapping context
    • of

      public static MappingContext of(Map<String,?> values)
      Creates a mapping context from the provided values.
      Parameters:
      values - the values to include
      Returns:
      the mapping context
    • builder

      public static MappingContext.Builder builder()
      Creates a fluent builder for a new mapping context.
      Returns:
      the mapping context builder
    • contains

      public boolean contains(String key)
      Returns whether the context contains the given key.
      Parameters:
      key - the key to check
      Returns:
      true if the key exists
    • isEmpty

      public boolean isEmpty()
      Returns whether the context contains no values.
      Returns:
      true when the context is empty
    • get

      public Object get(String key)
      Retrieves the raw value for the given key.
      Parameters:
      key - the key to look up
      Returns:
      the raw value or null if absent
    • get

      public <T> T get(String key, Class<T> type)
      Retrieves the typed value for the given key.
      Type Parameters:
      T - the expected type
      Parameters:
      key - the key to look up
      type - the expected type
      Returns:
      the typed value or null if absent
    • getOrDefault

      public <T> T getOrDefault(String key, T defaultValue)
      Retrieves a typed value or returns the supplied default.
      Type Parameters:
      T - the expected type
      Parameters:
      key - the key to look up
      defaultValue - the default value
      Returns:
      the value or the default
    • getOrDefault

      public <T> T getOrDefault(String key, Class<T> type, T defaultValue)
      Retrieves a typed value or returns the supplied default.
      Type Parameters:
      T - the expected type
      Parameters:
      key - the key to look up
      type - the expected type
      defaultValue - the default value
      Returns:
      the value or the default
    • asMap

      public Map<String,Object> asMap()
      Returns the context as an unmodifiable map.
      Returns:
      the context values
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object