Package pl.decerto.hyperon.runtime.core
Class AdhocContext
java.lang.Object
org.smartparam.engine.core.context.DefaultContext
pl.decerto.hyperon.runtime.core.HyperonContext
pl.decerto.hyperon.runtime.core.AdhocContext
- All Implemented Interfaces:
ParamContext
Deprecated.
This class helps to override default behaviour of
1. Invoking empty constructor, will simply return instance of AdhocContext for later usage.
2. Invoking constructor with first parameter as parent context. Must be type of
3. Invoking constructor with simple pair of parameters. Key/value, where key is path to element, value is any Object.
If there was mismatch with providing key/value pairs, then
Best usage of AdhocContext - parentContext + pairs that will override parent:
parent context with custom values.
There are few possibilities of creating proper AdhocContext instance:
1. Invoking empty constructor, will simply return instance of AdhocContext for later usage.
2. Invoking constructor with first parameter as parent context. Must be type of
DefaultContext.
Pairs of key/value (path/object) are optional.
3. Invoking constructor with simple pair of parameters. Key/value, where key is path to element, value is any Object.
If there was mismatch with providing key/value pairs, then
HyperonRuntimeException is thrown.
Best usage of AdhocContext - parentContext + pairs that will override parent:
HyperonContext base = new HyperonContext() // parent context
.set("a", 1)
.set("b", 2)
.set("c", 3);
AdhocContext ctx = new AdhocContext(base, "b", 222, "d", 444);
assertThat(ctx.get("a"), is(1));
assertThat(ctx.get("b"), is(222));
assertThat(ctx.get("c"), is(3));
assertThat(ctx.get("d"), is(444));
Empty constructor:
AdhocContext ctx = new AdhocContext(); // empty context
Create adhoc context without parent:
AdhocContext ctx = new AdhocContext("b", 222, "d", 444);
assertThat(ctx.get("a"), nullValue());
assertThat(ctx.get("b"), is(222));
assertThat(ctx.get("c"), nullValue());
assertThat(ctx.get("d"), is(444));
- Author:
- przemek hertel
-
Field Summary
Fields inherited from class pl.decerto.hyperon.runtime.core.HyperonContext
SKIP_PARENT -
Constructor Summary
ConstructorsConstructorDescriptionAdhocContext(Object... args) Deprecated.This constructor by design doesn't call super (parent constructor). -
Method Summary
Methods inherited from class pl.decerto.hyperon.runtime.core.HyperonContext
getBoolean, getBooleanHolder, getBooleanType, getDate, getDateHolder, getDatetime, getDatetimeHolder, getDatetimeType, getDateType, getDecimal, getFirst, getInteger, getIntegerHolder, getIntegerType, getLocalDate, getLocalDateHolder, getLocalDatetime, getLocalDatetimeHolder, getLocalDateTimeType, getLocalDateType, getNull, getNumber, getNumberHolder, getNumberType, getString, getStringHolder, getStringType, initialize, set, toStringMethods inherited from class org.smartparam.engine.core.context.DefaultContext
adhoc, get, get, getLevelValues, getUserContext, initialize, modifyKey, set, setLevelValues, with, with, withLevelValues, withLevelValues
-
Constructor Details
-
AdhocContext
Deprecated.This constructor by design doesn't call super (parent constructor).- Parameters:
args- possible scenarios of arguments: parentContext + pairs of path/value, only pairs of path/value, no parameters.
-
-
Method Details
-
get
Deprecated.get value from adhoc context or from parent (if not found in adhoc)- Overrides:
getin classHyperonContext- Parameters:
path- to be resolved when looking for object- Returns:
- object if path was successfully resolved, otherwise null
-
HigsonContext