Class AbstractDom<T>

java.lang.Object
pl.decerto.hyperon.domain.AbstractDom<T>
Type Parameters:
T - type T

public abstract class AbstractDom<T> extends Object
This class should be considered as wrapper class for HyperonDomainObject that will holds some extra informations, like children, context. It will also help you convert domain object properties to java types directly.
  • Field Details

  • Constructor Details

  • Method Details

    • defaultCtx

      protected HyperonContext defaultCtx(HyperonContext parent)
    • with

      public T with(HyperonContext ctx)
    • with

      public T with(String key, Object value)
    • with

      public T with(String key, HyperonContext subContext)
    • code

      public String code()
      Get code of domain object
      Returns:
      code of domain object as String
    • name

      public String name()
      Get name of domain object
      Returns:
      name of domain object as String
    • setStandardFields

      protected void setStandardFields(HyperonContext ctx)
      Setup default paths and values of domain object to the context. Values will be code, typeCode, name and callPath of domain object.
      Parameters:
      ctx - - appended context with values
    • getChildren

      protected List<HyperonDomainObject> getChildren(String propertyCode)
      Retrieves children from domain object, without wrapping them into AbstractDom type.
      Parameters:
      propertyCode - - property code for children defined in domain object
      Returns:
      list of children
    • getChild

      protected HyperonDomainObject getChild(String propertyCode, String code)
      Retrieves child from domain object, without wrapping it into AbstractDom type.
      Parameters:
      propertyCode - - property code for child defined in domain object
      code - - code for attribute
      Returns:
      child as instance of HyperonDomainObject
    • getChild

      protected <C extends AbstractDom> C getChild(String property, Function<HyperonDomainObject,C> mapper)
      Use this method for accessing domain property element. Ex. /property1/property2
      Type Parameters:
      C - returned DOM type
      Parameters:
      property - property path
      mapper - adapter factory
      Returns:
      domain object under given path
    • getChild

      protected <C extends AbstractDom> C getChild(String property, String code, Function<HyperonDomainObject,C> mapper)
      Use this method for accessing domain collection element. Ex.: /collectionProperty[collectionElementCode]
      Type Parameters:
      C - returned DOM type
      Parameters:
      property - property path
      code - collection element code
      mapper - adapter factory
      Returns:
      domain object under given path
    • hasChild

      protected boolean hasChild(String propertyCode, String code)
      Check if there is child (with code) under propery of domain object (with propertyCode)
      Parameters:
      propertyCode - - code of children within domain object
      code - - code of concrete child, that we want to check with
      Returns:
      true if child was found, false otherwise
    • getParent

      protected HyperonDomainObject getParent()
      Retrieves parent from domain object
      Returns:
      parent as of HyperonDomainObject type
    • all

      protected <R extends AbstractDom<R>> List<R> all(String childCode, Function<? super HyperonDomainObject,R> transform)
      Use this method for fetching children but they will be extra wrapped with subtypes of AbstractDOM with R type.
      Parameters:
      childCode - - code for children
      transform - - mapping function for returning proper AbstractDOM with R type
      Returns:
      Dom proxies for all children with [childCode]
    • one

      protected <R extends AbstractDom<R>> R one(String codeForChildren, String childCode, Function<? super HyperonDomainObject,R> transform)
      Use this method for fetching only one child, otherwise IllegalArgumentException will be thrown if there are "null" children or if there are more children under given childCode.
      Type Parameters:
      R - - result type
      Parameters:
      codeForChildren - - code for children
      childCode - - child's code to look
      transform - - mapping function for returning proper AbstractDOM with R type
      Returns:
      wrapped child with AbstractDOM type
    • one

      protected <R extends AbstractDom<R>> R one(String codeForChildren, Function<? super HyperonDomainObject,R> transform)
      Use this method for fetching only one child, otherwise IllegalArgumentException will be thrown if there are "null" children or if there are more children under given childCode.
      Type Parameters:
      R - - result type
      Parameters:
      codeForChildren - - code for children
      transform - - mapping function for returning proper AbstractDOM with R type
      Returns:
      wrapped child with AbstractDOM type
    • parent

      protected <R extends AbstractDom<R>> R parent(Function<? super HyperonDomainObject,R> transform)
      Retrieves parent, but also wrapped in subtype of AbstractDom using transform function.
      Type Parameters:
      R - - result type
      Parameters:
      transform - - function for wrapping domain object into subtype of AbastractDom
      Returns:
      new instance of AbstractDom with domain object within
    • getAttrValue

      protected ParamValue getAttrValue(String code, Object... args)
    • getAttrString

      protected String getAttrString(String code, Object... args)
    • getAttrBoolean

      protected boolean getAttrBoolean(String code, Object... functionArgs)
    • getAttrDecimal

      protected BigDecimal getAttrDecimal(String code, Object... args)
    • getAttrNumber

      protected double getAttrNumber(String code, Object... args)
    • getAttrInteger

      protected Integer getAttrInteger(String code, Object... args)
    • getAttrLong

      protected Long getAttrLong(String code, Object... args)
    • getAttrDate

      protected Date getAttrDate(String code, Object... args)
    • getAttrObject

      protected Object getAttrObject(String code, Object... args)
    • getAttrList

      protected <R> List<R> getAttrList(String code, Function<MultiValue,R> valueConverter, Object... args)
      Creates list of instances from attribute with given code. Method tries to map using given valueConverter from MultiValue type to R type.
      Type Parameters:
      R - - type of returned list
      Parameters:
      code - - code for MultiValue attribute
      valueConverter - - mapper for conversion
      args - - extra arguments
      Returns:
      list of type R
    • getAttrSet

      protected <R> Set<R> getAttrSet(String code, Function<MultiValue,R> valueConverter, Object... args)
      Creates set of instances from attribute with given code. Method tries to map using given valueConverter from MultiValue type to R type.
      Type Parameters:
      R - - type of returned list
      Parameters:
      code - - code for MultiValue attribute
      valueConverter - - mapper for conversion
      args - - extra arguments
      Returns:
      list of type R
    • getAttrEnum

      protected <R extends Enum<R>> R getAttrEnum(Class<R> enumType, String code, Object... args)
    • getAttrStringList

      protected List<String> getAttrStringList(String code)
      Retrieves list of string based on code attribute. Parameter value under code attribute must be of MultiValue type. Method will take only first position(column) from MultiValue and try to convert it to String.
      Parameters:
      code - - code attribute in domain
      Returns:
      list of strings from first MultiValue column
    • getAttrStringSet

      protected Set<String> getAttrStringSet(String code)
      Retrieves set of string based on code attribute. Parameter value under code attribute must be of MultiValue type. Method will take only first position(column) from MultiValue and try to convert it to String.
      Parameters:
      code - - code attribute in domain
      Returns:
      set of strings from first MultiValue column
    • getDynamicAttrValue

      protected ParamValue getDynamicAttrValue(String code, Object... args)
    • getDynamicAttrString

      protected String getDynamicAttrString(String code, Object... args)
    • getDynamicAttrDecimal

      protected BigDecimal getDynamicAttrDecimal(String code, Object... args)
    • getDynamicAttrNumber

      protected double getDynamicAttrNumber(String code, Object... args)
    • getDynamicAttrInteger

      protected Integer getDynamicAttrInteger(String code, Object... args)
    • getDynamicAttrLong

      protected Long getDynamicAttrLong(String code, Object... args)
    • getDynamicAttrDate

      protected Date getDynamicAttrDate(String code, Object... args)
    • getDynamicAttrBoolean

      protected boolean getDynamicAttrBoolean(String code, Object... args)
    • getDynamicAttrObject

      protected Object getDynamicAttrObject(String code, Object... args)
    • getDynamicAttrEnum

      protected <R extends Enum<R>> R getDynamicAttrEnum(Class<R> enumType, String code, Object... args)
    • getDynamicAttrList

      protected <R> List<R> getDynamicAttrList(String code, Function<MultiValue,R> valueConverter, Object... args)
      Creates list of instances from dynamic attribute with given code. Method tries to map using given valueConverter from MultiValue type to R type.
      Type Parameters:
      R - - type of returned list
      Parameters:
      code - - code for MultiValue dynamic attribute
      valueConverter - - mapper for conversion
      args - - extra arguments
      Returns:
      list of type R
    • getDynamicAttrSet

      protected <R> Set<R> getDynamicAttrSet(String code, Function<MultiValue,R> valueConverter, Object... args)
      Creates set of instances from dynamic attribute with given code. Method tries to map using given valueConverter from MultiValue type to R type.
      Type Parameters:
      R - - type of returned list
      Parameters:
      code - - code for MultiValue dynamic attribute
      valueConverter - - mapper for conversion
      args - - extra arguments
      Returns:
      list of type R
    • getDynamicAttrStringList

      protected List<String> getDynamicAttrStringList(String code)
      Retrieves set of string based on dynamic code attribute. Parameter value under dynamic code attribute must be of MultiValue type. Method will take only first position(column) from MultiValue and try to convert it to String.
      Parameters:
      code - - code attribute in domain
      Returns:
      set of strings from first MultiValue column
    • getDynamicAttrStringSet

      protected Set<String> getDynamicAttrStringSet(String code)
      Retrieves set of string based on dynamic code attribute. Parameter value under dynamic code attribute must be of MultiValue type. Method will take only first position(column) from MultiValue and try to convert it to String.
      Parameters:
      code - - code attribute in domain
      Returns:
      set of strings from first MultiValue column
    • toString

      public String toString()
      Overrides:
      toString in class Object