Package io.higson.runtime.domain
Class AbstractDom<T>
java.lang.Object
io.higson.runtime.domain.AbstractDom<T>
- Type Parameters:
T- type T
This class should be considered as wrapper class for HigsonDomainObject that will holds some extra informations, like children, context.
It will also help you convert domain object properties to java types directly.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HigsonContexthigson context to useprotected final DomainObjectdomain object to useprotected TypeConvertertype converter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <R extends AbstractDom<R>>
List<R>all(String childCode, Function<? super DomainObject, R> transform) Use this method for fetching children but they will be extra wrapped with subtypes of AbstractDOM with R type.code()Get code of domain objectprotected HigsonContextdefaultCtx(HigsonContext parent) protected booleangetAttrBoolean(String code, Object... functionArgs) protected DategetAttrDate(String code, Object... args) protected BigDecimalgetAttrDecimal(String code, Object... args) protected <R extends Enum<R>>
RgetAttrEnum(Class<R> enumType, String code, Object... args) protected IntegergetAttrInteger(String code, Object... args) protected <R> List<R>getAttrList(String code, Function<MultiValue, R> valueConverter, Object... args) Creates list of instances from attribute with given code.protected LonggetAttrLong(String code, Object... args) protected doublegetAttrNumber(String code, Object... args) protected ObjectgetAttrObject(String code, Object... args) protected <R> Set<R>getAttrSet(String code, Function<MultiValue, R> valueConverter, Object... args) Creates set of instances from attribute with given code.protected StringgetAttrString(String code, Object... args) getAttrStringList(String code) Retrieves list of string based on code attribute.getAttrStringSet(String code) Retrieves set of string based on code attribute.protected ParamValuegetAttrValue(String code, Object... args) protected DomainObjectRetrieves child from domain object, without wrapping it into AbstractDom type.protected <C extends AbstractDom>
CgetChild(String property, String code, Function<DomainObject, C> mapper) Use this method for accessing domain collection element.protected <C extends AbstractDom>
CgetChild(String property, Function<DomainObject, C> mapper) Use this method for accessing domain property element.protected List<DomainObject>getChildren(String propertyCode) Retrieves children from domain object, without wrapping them into AbstractDom type.protected booleangetDynamicAttrBoolean(String code, Object... args) protected DategetDynamicAttrDate(String code, Object... args) protected BigDecimalgetDynamicAttrDecimal(String code, Object... args) protected <R extends Enum<R>>
RgetDynamicAttrEnum(Class<R> enumType, String code, Object... args) protected IntegergetDynamicAttrInteger(String code, Object... args) protected <R> List<R>getDynamicAttrList(String code, Function<MultiValue, R> valueConverter, Object... args) Creates list of instances from dynamic attribute with given code.protected LonggetDynamicAttrLong(String code, Object... args) protected doublegetDynamicAttrNumber(String code, Object... args) protected ObjectgetDynamicAttrObject(String code, Object... args) protected <R> Set<R>getDynamicAttrSet(String code, Function<MultiValue, R> valueConverter, Object... args) Creates set of instances from dynamic attribute with given code.protected StringgetDynamicAttrString(String code, Object... args) Retrieves set of string based on dynamic code attribute.Retrieves set of string based on dynamic code attribute.protected ParamValuegetDynamicAttrValue(String code, Object... args) protected DomainObjectRetrieves parent from domain objectprotected booleanCheck if there is child (with code) under propery of domain object (with propertyCode)name()Get name of domain objectprotected <R extends AbstractDom<R>>
Rone(String codeForChildren, String childCode, Function<? super DomainObject, 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.protected <R extends AbstractDom<R>>
Rone(String codeForChildren, Function<? super DomainObject, 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.protected <R extends AbstractDom<R>>
Rparent(Function<? super DomainObject, R> transform) Retrieves parent, but also wrapped in subtype of AbstractDom using transform function.protected voidSetup default paths and values of domain object to the context.toString()with(HigsonContext ctx) with(String key, HigsonContext subContext)
-
Field Details
-
domObj
domain object to use -
ctx
higson context to use -
typeConverter
type converter
-
-
Constructor Details
-
AbstractDom
-
-
Method Details
-
defaultCtx
-
with
-
with
-
with
-
code
Get code of domain object- Returns:
- code of domain object as String
-
name
Get name of domain object- Returns:
- name of domain object as String
-
setStandardFields
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
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
Retrieves child from domain object, without wrapping it into AbstractDom type.- Parameters:
propertyCode- - property code for child defined in domain objectcode- - code for attribute- Returns:
- child as instance of HigsonDomainObject
-
getChild
Use this method for accessing domain property element. Ex. /property1/property2- Type Parameters:
C- returned DOM type- Parameters:
property- property pathmapper- adapter factory- Returns:
- domain object under given path
-
getChild
protected <C extends AbstractDom> C getChild(String property, String code, Function<DomainObject, C> mapper) Use this method for accessing domain collection element. Ex.: /collectionProperty[collectionElementCode]- Type Parameters:
C- returned DOM type- Parameters:
property- property pathcode- collection element codemapper- adapter factory- Returns:
- domain object under given path
-
hasChild
Check if there is child (with code) under propery of domain object (with propertyCode)- Parameters:
propertyCode- - code of children within domain objectcode- - code of concrete child, that we want to check with- Returns:
- true if child was found, false otherwise
-
getParent
Retrieves parent from domain object- Returns:
- parent as of HigsonDomainObject type
-
all
protected <R extends AbstractDom<R>> List<R> all(String childCode, Function<? super DomainObject, 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 childrentransform- - 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 DomainObject, 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 childrenchildCode- - child's code to looktransform- - 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 DomainObject, 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 childrentransform- - mapping function for returning proper AbstractDOM with R type- Returns:
- wrapped child with AbstractDOM type
-
parent
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
-
getAttrString
-
getAttrBoolean
-
getAttrDecimal
-
getAttrNumber
-
getAttrInteger
-
getAttrLong
-
getAttrDate
-
getAttrObject
-
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 attributevalueConverter- - mapper for conversionargs- - extra arguments- Returns:
- list of type R
-
getAttrSet
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 attributevalueConverter- - mapper for conversionargs- - extra arguments- Returns:
- list of type R
-
getAttrEnum
-
getAttrStringList
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
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
-
getDynamicAttrString
-
getDynamicAttrDecimal
-
getDynamicAttrNumber
-
getDynamicAttrInteger
-
getDynamicAttrLong
-
getDynamicAttrDate
-
getDynamicAttrBoolean
-
getDynamicAttrObject
-
getDynamicAttrEnum
-
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 attributevalueConverter- - mapper for conversionargs- - 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 attributevalueConverter- - mapper for conversionargs- - extra arguments- Returns:
- list of type R
-
getDynamicAttrStringList
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
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
-