Class HyperonContext

java.lang.Object
org.smartparam.engine.core.context.DefaultContext
pl.decerto.hyperon.runtime.core.HyperonContext
All Implemented Interfaces:
ParamContext
Direct Known Subclasses:
AdhocContext, HyperonSubContext

@Deprecated public class HyperonContext extends DefaultContext
Deprecated.
Author:
przemek hertel
  • Field Details

    • SKIP_PARENT

      protected static final Object SKIP_PARENT
      Deprecated.
  • Constructor Details

    • HyperonContext

      public HyperonContext(Object... args)
      Deprecated.
  • Method Details

    • set

      public HyperonContext set(String path, Object value)
      Deprecated.
      Put given value object under specified path.
      Parameters:
      path - where object will be stored
      value - any object
      Returns:
      the same context instance with stored value under the path
      Throws:
      DuplicateContextItemException - if path was already in use
    • get

      public Object get(String path)
      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:
      get in class DefaultContext
      Parameters:
      path - to be resolved when looking for object
      Returns:
      object if path was successfully resolved, otherwise null
    • getFirst

      public Object getFirst(String path)
      Deprecated.
      Tries to resolve path the same way as method get(String), but object under this path must implement Iterable. 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

      protected Object getNull()
      Deprecated.
    • getStringHolder

      public StringHolder getStringHolder(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value wrapped into StringHolder with some String support.

      Example:
      
       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

      public String getString(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value as String.

      Example:
      
        HyperonContext ctx = new HyperonContext("policy.status", "AA");
        assertThat(ctx.getString("policy.status"), is("AA"));
       
      Overrides:
      getString in class DefaultContext
      Parameters:
      path - to be resolved and looking for value
      Returns:
      value as String or null if not found
      See Also:
    • getNumberHolder

      public NumberHolder getNumberHolder(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value wrapped into NumberHolder with some number support.

      Example:
      
      	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

      public BigDecimal getDecimal(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value as BigDecimal.

      Example:
      
        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

      public double getNumber(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value as double.

      Example:
      
        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

      public IntegerHolder getIntegerHolder(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value wrapped into IntegerHolder with some integer support.

      Example:
      
        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

      public Integer getInteger(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value as Integer.

      Example:
      
        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

      public DateHolder getDateHolder(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value wrapped into DateHolder with some Date support.

      Example:
      
       	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

      public Date getDate(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value as Date with date format.

      Example:
      
       	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

      public LocalDateHolder getLocalDateHolder(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value wrapped into LocalDateHolder with some LocalDate support.

      Example:
      
       	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

      public LocalDate getLocalDate(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value as LocalDate with date format.

      Example:
      
       	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

      public DatetimeHolder getDatetimeHolder(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value wrapped into DatetimeHolder with some Date support.

      Example:
      
       	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

      public Date getDatetime(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value as Date with date and time format.

      Example:
      
       		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

      public LocalDateTimeHolder getLocalDatetimeHolder(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value wrapped into LocalDatetimeHolder with some LocalDateTime support.

      Example:
      
       	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

      public LocalDateTime getLocalDatetime(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value as LocalDateTime with date and time format.

      Example:
      
       		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

      public BooleanHolder getBooleanHolder(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value wrapped into BooleanHolder with some boolean support.

      Example:
      
       	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

      public boolean getBoolean(String path)
      Deprecated.

      Tries to resolve path the same way as method get(String) and then return value as boolean.

      Example:
      
      	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

      public static void initialize(TypesDto dto)
      Deprecated.
      Initialized supported types.
      Parameters:
      dto - with supported types
    • getStringType

      public static StringType 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

      public static NumberType 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

      public static IntegerType 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

      public static BooleanType 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

      public static DateType 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
      Example:
      
       	DateType type = ctx.getDateType();
       	DateHolder holder = type.decode("2018-10-29");
       
      Returns:
      supported DateType with Date Holder
    • getLocalDateType

      public static LocalDateType 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
      Example:
      
       	LocalDate type = ctx.getLocalDateType();
       	LocalDateHolder holder = type.decode("2018-10-29");
       
      Returns:
      supported LocalDateType with LocalDate Holder
    • getDatetimeType

      public static DatetimeType 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
      Example:
      
       		DatetimeType type = ctx.getDatetimeType();
       		DatetimeHolder holder = type.decode("2018-07-31 14:56:07.627");
       
      Returns:
      supported DatetimeType with Datetime Holder
    • getLocalDateTimeType

      public static LocalDateTimeType 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
      Example:
      
       		LocalDateTimeType type = ctx.getLocalDateTimeType();
       		LocalDateTimeHolder holder = type.decode("2018-07-31 14:56:07.627");
       
      Returns:
      supported LocalDateTimeType with LocalDateTime Holder
    • toString

      public String toString()
      Deprecated.
      Overrides:
      toString in class DefaultContext