Class HyperonContext
- All Implemented Interfaces:
ParamContext
- Direct Known Subclasses:
AdhocContext,HyperonSubContext
- Author:
- przemek hertel
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Tries to resolve given path and return object from the context.booleangetBoolean(String path) Deprecated.Tries to resolve path the same way as methodget(String)and then return value as boolean.getBooleanHolder(String path) Deprecated.Tries to resolve path the same way as methodget(String)and then return value wrapped into BooleanHolder with some boolean support.static BooleanTypeDeprecated.Get Boolean type instance used by Higson.Deprecated.Tries to resolve path the same way as methodget(String)and then return value as Date with date format.getDateHolder(String path) Deprecated.Tries to resolve path the same way as methodget(String)and then return value wrapped into DateHolder with some Date support.getDatetime(String path) Deprecated.Tries to resolve path the same way as methodget(String)and then return value as Date with date and time format.getDatetimeHolder(String path) Deprecated.Tries to resolve path the same way as methodget(String)and then return value wrapped into DatetimeHolder with some Date support.static DatetimeTypeDeprecated.Get Datetime type instance used by Higson.static DateTypeDeprecated.Get Date type instance used by Higson.getDecimal(String path) Deprecated.Tries to resolve path the same way as methodget(String)and then return value as BigDecimal.Deprecated.Tries to resolve path the same way as methodget(String), but object under this path must implementIterable.getInteger(String path) Deprecated.Tries to resolve path the same way as methodget(String)and then return value as Integer.getIntegerHolder(String path) Deprecated.Tries to resolve path the same way as methodget(String)and then return value wrapped into IntegerHolder with some integer support.static IntegerTypeDeprecated.Get Integer type instance used by Higson.getLocalDate(String path) Deprecated.Tries to resolve path the same way as methodget(String)and then return value as LocalDate with date format.getLocalDateHolder(String path) Deprecated.Tries to resolve path the same way as methodget(String)and then return value wrapped into LocalDateHolder with some LocalDate support.getLocalDatetime(String path) Deprecated.Tries to resolve path the same way as methodget(String)and then return value as LocalDateTime with date and time format.getLocalDatetimeHolder(String path) Deprecated.Tries to resolve path the same way as methodget(String)and then return value wrapped into LocalDatetimeHolder with some LocalDateTime support.static LocalDateTimeTypeDeprecated.Get LocalDateTime type instance used by Higson.static LocalDateTypeDeprecated.Get LocalDate type instance used by Higson.protected ObjectgetNull()Deprecated.doubleDeprecated.Tries to resolve path the same way as methodget(String)and then return value as double.getNumberHolder(String path) Deprecated.Tries to resolve path the same way as methodget(String)and then return value wrapped into NumberHolder with some number support.static NumberTypeDeprecated.Get Number type instance used by Higson.Deprecated.Tries to resolve path the same way as methodget(String)and then return value as String.getStringHolder(String path) Deprecated.Tries to resolve path the same way as methodget(String)and then return value wrapped into StringHolder with some String support.static StringTypeDeprecated.Get String type instance used by Higson.static voidinitialize(TypesDto dto) Deprecated.Initialized supported types.Deprecated.Put given value object under specified path.toString()Deprecated.Methods inherited from class org.smartparam.engine.core.context.DefaultContext
adhoc, get, get, getLevelValues, getUserContext, initialize, modifyKey, set, setLevelValues, with, with, withLevelValues, withLevelValues
-
Field Details
-
SKIP_PARENT
Deprecated.
-
-
Constructor Details
-
HyperonContext
Deprecated.
-
-
Method Details
-
set
Deprecated.Put given value object under specified path.- Parameters:
path- where object will be storedvalue- any object- Returns:
- the same context instance with stored value under the path
- Throws:
DuplicateContextItemException- if path was already in use
-
get
Deprecated.Tries to resolve given path and return object from the context. If the object is not found at first try, then method is looking for objects by resolving subPath. SubPath is created by stripping given path (between first occurrence of '.' character) into first token and the rest of the path. If stripping was successful and first token is an existing object in context, then algorithm tries to use it as a subContext for the subPath. The more objects exists in depth in context, the longer it might take to resolve them.
Examples:HyperonContext ctx = new HyperonContext("policy.status", "AA"); Object s1 = ctx.get("policy.status"); // found object Object s2 = ctx.get("policy.info"); // s2 is null here, since there is not object with this path defined in cotext // Sample with parent context and subContext HyperonContext policyCtx = new HyperonContext().set("status", "AA"); HyperonContext ctx = new HyperonContext().set("policy", policyCtx); assertThat(ctx.getString("policy.status"), is("AA")); assertThat(ctx.getString("policy.info"), nullValue()); assertThat(ctx.getString("user.name"), nullValue());- Overrides:
getin classDefaultContext- Parameters:
path- to be resolved when looking for object- Returns:
- object if path was successfully resolved, otherwise null
-
getFirst
Deprecated.Tries to resolve path the same way as methodget(String), but object under this path must implementIterable. If it does, then the first object is returned from Iterable, but which first object is returned, that depends on used collection.- Parameters:
path- to be resolved and looking for collection- Returns:
- first object from collection under path if found, null otherwise
-
getNull
Deprecated. -
getStringHolder
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value wrapped into StringHolder with some String support.HyperonContext ctx = new HyperonContext("policy.status", "AA"); StringHolder s1 = ctx.getStringHolder("policy.status"); assertThat(s1.getString(), is("AA")); assertThat(s1.isBlank(), is(false));- Parameters:
path- to be resolved and looking for value- Returns:
- wrapped value or null if not found into StringHolder
-
getString
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value as String.HyperonContext ctx = new HyperonContext("policy.status", "AA"); assertThat(ctx.getString("policy.status"), is("AA"));- Overrides:
getStringin classDefaultContext- Parameters:
path- to be resolved and looking for value- Returns:
- value as String or null if not found
- See Also:
-
getNumberHolder
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value wrapped into NumberHolder with some number support.HyperonContext ctx = new HyperonContext("policy.factor", "1.23"); NumberHolder s1 = ctx.getNumberHolder("policy.factor"); assertThat(h1.getBigDecimal(), is(new BigDecimal("1.23"))); assertEquals(1.23, h1.doubleValue(), 1e-6);- Parameters:
path- to be resolved and looking for value- Returns:
- wrapped value or null if not found into NumberHolder
-
getDecimal
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value as BigDecimal.HyperonContext ctx = new HyperonContext("factor", "1,23"); assertThat(ctx.getDecimal("factor"), is(new BigDecimal("1.23")));- Parameters:
path- to be resolved and looking for value- Returns:
- value as BigDecimal or null if not found
-
getNumber
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value as double.HyperonContext ctx = new HyperonContext("factor", "1,23"); assertEquals(1.23, ctx.getNumber("factor"), 1e-6); assertThat(ctx.getNumber("factory"), is(0.0));- Parameters:
path- to be resolved and looking for value- Returns:
- value as double or 0.0 if not found
-
getIntegerHolder
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value wrapped into IntegerHolder with some integer support.HyperonContext ctx = new HyperonContext("count", "123"); assertThat(ctx.getIntegerHolder("count").intValue(), is(123)); assertThat(ctx.getIntegerHolder("counter").getInteger(), nullValue());- Parameters:
path- to be resolved and looking for value- Returns:
- wrapped value or null if not found into IntegerHolder
-
getInteger
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value as Integer.HyperonContext ctx = new HyperonContext().set("count", "123"); assertThat(ctx.getInteger("count"), is(123)); assertThat(ctx.getInteger("counter"), nullValue());- Parameters:
path- to be resolved and looking for value- Returns:
- value as Integer or null if not found
-
getDateHolder
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value wrapped into DateHolder with some Date support.Date rcd = new Date(); HyperonContext ctx = new HyperonContext("policy.rcd", rcd); DateHolder h1 = ctx.getDateHolder("policy.rcd"); assertThat(h1.getDate(), sameInstance(rcd));- Parameters:
path- to be resolved and looking for value- Returns:
- wrapped value or null if not found into DateHolder
-
getDate
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value as Date with date format.Date rcd = new Date(); HyperonContext ctx = new HyperonContext("policy.rcd", rcd); assertThat(ctx.getDate("policy.rcd"), sameInstance(rcd));- Parameters:
path- to be resolved and looking for value- Returns:
- value as Date or null if not found
-
getLocalDateHolder
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value wrapped into LocalDateHolder with some LocalDate support.LocalDate rcd = new LocalDate(); HyperonContext ctx = new HyperonContext("policy.rcd", rcd); LocalDateHolder h1 = ctx.getLocalDateHolder("policy.rcd"); assertThat(h1.getLocalDate(), sameInstance(rcd));- Parameters:
path- to be resolved and looking for value- Returns:
- wrapped value or null if not found into LocalDateHolder
-
getLocalDate
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value as LocalDate with date format.LocalDate rcd = new LocalDate(); HyperonContext ctx = new HyperonContext("policy.rcd", rcd); assertThat(ctx.getLocalDate("policy.rcd"), sameInstance(rcd));- Parameters:
path- to be resolved and looking for value- Returns:
- value as LocalDate or null if not found
-
getDatetimeHolder
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value wrapped into DatetimeHolder with some Date support.Date rcd = new Date(); HyperonContext ctx = new HyperonContext("policy.rcd", rcd); DatetimeHolder h1 = ctx.getDatetimeHolder("policy.rcd"); assertThat(h1.getDatetime(), sameInstance(rcd));- Parameters:
path- to be resolved and looking for value- Returns:
- wrapped value or null if not found into DatetimeHolder
-
getDatetime
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value as Date with date and time format.Date rcd = new Date(); HyperonContext ctx = new HyperonContext("policy.rcd", rcd); assertThat(ctx.getDatetime("policy.rcd"), sameInstance(rcd));- Parameters:
path- to be resolved and looking for value- Returns:
- value as Date or null if not found
-
getLocalDatetimeHolder
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value wrapped into LocalDatetimeHolder with some LocalDateTime support.LocalDateTime rcd = new LocalDateTime(); HyperonContext ctx = new HyperonContext("policy.rcd", rcd); LocalDateTimeHolder h1 = ctx.getLocalDatetimeHolder("policy.rcd"); assertThat(h1.getLocalDateTime(), sameInstance(rcd));- Parameters:
path- to be resolved and looking for value- Returns:
- wrapped value or null if not found into LocalDatetimeHolder
-
getLocalDatetime
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value as LocalDateTime with date and time format.LocalDateTime rcd = new LocalDateTime(); HyperonContext ctx = new HyperonContext("policy.rcd", rcd); assertThat(ctx.getLocalDateTime("policy.rcd"), sameInstance(rcd));- Parameters:
path- to be resolved and looking for value- Returns:
- value as LocalDateTime or null if not found
-
getBooleanHolder
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value wrapped into BooleanHolder with some boolean support.HyperonContext ctx = new HyperonContext().set("flag1", "tak").set("flag2", "no"); assertThat(ctx.getBooleanHolder("flag1").booleanValue(), is(true)); assertThat(ctx.getBooleanHolder("flag1").getBoolean(), is(true)); assertThat(ctx.getBooleanHolder("flag2").getBoolean(), is(false)); assertThat(ctx.getBooleanHolder("flag2").booleanValue(), is(false));- Parameters:
path- to be resolved and looking for value- Returns:
- wrapped value or null if not found into BooleanHolder
-
getBoolean
Deprecated.Tries to resolve path the same way as method
Example:get(String)and then return value as boolean.HyperonContext ctx = new HyperonContext().set("flag1", "tak").set("flag2", "no"); assertThat(ctx.getBoolean("flag1"), is(true)); assertThat(ctx.getBoolean("flag2"), is(false));- Parameters:
path- to be resolved and looking for value- Returns:
- value as boolean or false if not found
-
initialize
Deprecated.Initialized supported types.- Parameters:
dto- with supported types
-
getStringType
Deprecated.Get String type instance used by Higson. It might be used for wrapping String into recognizable type by Higson, trying out conversions, encoding and decoding supported by engine.
Example:StringType type = ctx.getStringType(); StringHolder holder = type.convert(new Integer(17)); // 17 == holder.getValue()- Returns:
- supported StringType with String Holder
-
getNumberType
Deprecated.Get Number type instance used by Higson. It might be used for wrapping Number into recognizable type by Higson, trying out conversions, encoding and decoding supported by engine.
Example:NumberType type = ctx.getNumberType(); NumberHolder holder = type.decode("1143.54");- Returns:
- supported NumberType with Number Holder
-
getIntegerType
Deprecated.Get Integer type instance used by Higson. It might be used for wrapping Integer into recognizable type by Higson, trying out conversions, encoding and decoding supported by engine.
Example:IntegerType type = ctx.getIntegerType(); IntegerHolder holder = type.decode("1143");- Returns:
- supported IntegerType with Integer Holder
-
getBooleanType
Deprecated.Get Boolean type instance used by Higson. It might be used for wrapping Boolean into recognizable type by Higson, trying out conversions, encoding and decoding supported by engine.
Example:BooleanType type = ctx.getBooleanType(); BooleanType holder = type.decode("tak"); BooleanType holder = type.decode("y"); BooleanType holder = type.decode("yes"); BooleanType holder = type.decode("1");- Returns:
- supported BooleanType with Boolean Holder
-
getDateType
Deprecated.Get Date type instance used by Higson. It might be used for wrapping Date into recognizable type by Higson, trying out conversions, encoding and decoding supported by engine.
Supported formats:- yyyy-MM-dd - default
- dd-MM-yyyy
- dd.MM.yyyy
- dd/MM/yyyy
- yyyy-MM-dd
- yyyy.MM.dd
- yyyy/MM/dd
DateType type = ctx.getDateType(); DateHolder holder = type.decode("2018-10-29");- Returns:
- supported DateType with Date Holder
-
getLocalDateType
Deprecated.Get LocalDate type instance used by Higson. It might be used for wrapping LocalDate into recognizable type by Higson, trying out conversions, encoding and decoding supported by engine.
Supported formats:- yyyy-MM-dd - default
- dd-MM-yyyy
- dd.MM.yyyy
- dd/MM/yyyy
- yyyy-MM-dd
- yyyy.MM.dd
- yyyy/MM/dd
LocalDate type = ctx.getLocalDateType(); LocalDateHolder holder = type.decode("2018-10-29");- Returns:
- supported LocalDateType with LocalDate Holder
-
getDatetimeType
Deprecated.Get Datetime type instance used by Higson. It might be used for wrapping Date into recognizable type by Higson, trying out conversions, encoding and decoding supported by engine.
Supported formats:- yyyy-MM-dd HH:mm:ss.SSS - default
- dd-MM-yyyy HH:mm:ss.SSS
- dd.MM.yyyy HH:mm:ss.SSS
- dd/MM/yyyy HH:mm:ss.SSS
- yyyy-MM-dd HH:mm:ss.SSS
- yyyy.MM.dd HH:mm:ss.SSS
- yyyy/MM/dd HH:mm:ss.SSS
DatetimeType type = ctx.getDatetimeType(); DatetimeHolder holder = type.decode("2018-07-31 14:56:07.627");- Returns:
- supported DatetimeType with Datetime Holder
-
getLocalDateTimeType
Deprecated.Get LocalDateTime type instance used by Higson. It might be used for wrapping LocalDateTime into recognizable type by Higson, trying out conversions, encoding and decoding supported by engine.
Supported formats:- yyyy-MM-dd HH:mm:ss.SSS - default
- dd-MM-yyyy HH:mm:ss.SSS
- dd.MM.yyyy HH:mm:ss.SSS
- dd/MM/yyyy HH:mm:ss.SSS
- yyyy-MM-dd HH:mm:ss.SSS
- yyyy.MM.dd HH:mm:ss.SSS
- yyyy/MM/dd HH:mm:ss.SSS
- DateTimeFormatter.ISO_LOCAL_DATE_TIME
- DateTimeFormatter.ISO_OFFSET_DATE_TIME
- DateTimeFormatter.ISO_ZONED_DATE_TIME
- DateTimeFormatter.ISO_DATE_TIME
- DateTimeFormatter.RFC_1123_DATE_TIME
LocalDateTimeType type = ctx.getLocalDateTimeType(); LocalDateTimeHolder holder = type.decode("2018-07-31 14:56:07.627");- Returns:
- supported LocalDateTimeType with LocalDateTime Holder
-
toString
Deprecated.- Overrides:
toStringin classDefaultContext
-
HigsonContext