Package com.helixframework.mapper
Class MappingContext
java.lang.Object
com.helixframework.mapper.MappingContext
Immutable mapping context passed to mapper operations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFluent builder for immutable mapping contexts. -
Method Summary
Modifier and TypeMethodDescriptionasMap()Returns the context as an unmodifiable map.static MappingContext.Builderbuilder()Creates a fluent builder for a new mapping context.booleanReturns whether the context contains the given key.static MappingContextempty()Returns an empty mapping context.booleanRetrieves the raw value for the given key.<T> TRetrieves the typed value for the given key.<T> TgetOrDefault(String key, Class<T> type, T defaultValue) Retrieves a typed value or returns the supplied default.<T> TgetOrDefault(String key, T defaultValue) Retrieves a typed value or returns the supplied default.inthashCode()booleanisEmpty()Returns whether the context contains no values.static MappingContextCreates a mapping context from the provided values.toString()
-
Method Details
-
empty
Returns an empty mapping context.- Returns:
- the empty mapping context
-
of
Creates a mapping context from the provided values.- Parameters:
values- the values to include- Returns:
- the mapping context
-
builder
Creates a fluent builder for a new mapping context.- Returns:
- the mapping context builder
-
contains
Returns whether the context contains the given key.- Parameters:
key- the key to check- Returns:
trueif the key exists
-
isEmpty
public boolean isEmpty()Returns whether the context contains no values.- Returns:
truewhen the context is empty
-
get
Retrieves the raw value for the given key.- Parameters:
key- the key to look up- Returns:
- the raw value or
nullif absent
-
get
Retrieves the typed value for the given key.- Type Parameters:
T- the expected type- Parameters:
key- the key to look uptype- the expected type- Returns:
- the typed value or
nullif absent
-
getOrDefault
Retrieves a typed value or returns the supplied default.- Type Parameters:
T- the expected type- Parameters:
key- the key to look updefaultValue- the default value- Returns:
- the value or the default
-
getOrDefault
Retrieves a typed value or returns the supplied default.- Type Parameters:
T- the expected type- Parameters:
key- the key to look uptype- the expected typedefaultValue- the default value- Returns:
- the value or the default
-
asMap
Returns the context as an unmodifiable map.- Returns:
- the context values
-
equals
-
hashCode
public int hashCode() -
toString
-