Package io.higson.runtime.model.value
Interface Handle
- All Known Implementing Classes:
Bundle,CollectionProperty,EntityProperty,Property,RefProperty,ValueProperty
This interface should be only used within Higson Persistence Engine as grouping facade of all possible actions on it's subclasses.
What's important is that collection property type allows iteration thanks to (Iterable).
- Author:
- przemek hertel
- API Note:
- It might be removed in the future, or broke apart into smaller interfaces, which group common behaviour, like collection methods, references, etc.
-
Method Summary
Modifier and TypeMethodDescriptionAdds one or multiple properties to collection property.Adds one or multiple properties to collection property, that exists under givenpath.asEntity()asRef()asValue()at(int index) Gets property at givenindexwithingthisproperty.booleanbooleanbooleanValue(String path) Gets value as boolean from givenpath.clear()Clear all children ofthisproperty.create()default Propertyfind(long id) Find child property by id.Gets property under givenpath.getBoolean(String path) Gets value as Boolean from givenpath.getCollection(String path) Find collection property based on givenpathwithin this property subtree.getDate()Gets value as Date from givenpath.getDatetime(String path) Gets value as Date with time from givenpath.getDecimal(String path) Gets value as BigDecimal from givenpath.Gets associated element type, based on property implementation.Find entity property based on givenpathwithin this property subtree.Gets value of property wrapped intoValueHolderfrom givenpath.getInteger(String path) Gets value as Integer from givenpath.getLong()Gets value as Long from givenpath.doubledoubleGets value as double from givenpath.intNumber of nodes referencing target's property.Gets property of reference's target.getState()Gets state of property.Gets value as String from givenpath.default booleanChecks if this property has element of givenpath.intintValue()intGets value as int from givenpath.default booleanIs property a collection type.default booleanisEntity()Is property an entity.booleanIs property in persistent state.default booleanisRef()Is property a reference type.default booleanisRoot()Is property a root element.booleanIs property in transient state.default booleanisValue()Is property a value type.print()Creates whole sub tree of this property as formatted String.remove()Removes itself.Removes property from givenpath.voidSets newvalueof this property.Sets newvalueunder givenpath, which must exists.intsize()voidtraverse(PropertyVisitor visitor) This method walks on property subtree and invoke some action withPropertyVisitor.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
get
Gets property under givenpath. There are few path resolving possibilities:
If path is empty or null, property should return itself.1. Direct access to child property (element, reference, value or collection) property.get("child") - direct child property property.get("children") - direct children collection property property.get("child.name") - indirect child's name property as value 2. Access to collection element at available index property.get("children.id") - is not possible, if "children" is collection property property.get("children[0].id") - proper access to child, that exists within children collection 3. Chain of properties property.get("supplier.car.model.productionYear")- Implementation Requirements:
- property elements should be separated by . (dot char).
- Parameters:
path- should exists within this property- Returns:
- property if path was properly resolved and property exists, null otherwise
- See Also:
-
set
Sets newvalueunder givenpath, which must exists. All rules of path design, are the same as described inget(String).
Example:
This method is useful for setting up multiple properties of one parent property, in the sense of Builder Pattern.Property agent = property.get("agent").set("age", 31).set("name", "steph");- Implementation Requirements:
- new value might override previous value. It depends on exact implementation.
- Parameters:
path- should exists within this propertyvalue- new value for path.- Returns:
- same property instance.
- See Also:
-
set
Sets newvalueof this property.- Implementation Requirements:
- specific behaviour may vary for each implementation.
- Parameters:
value- new value
-
find
Find child property by id.- Implementation Requirements:
- default implementation will return null.
- Parameters:
id- child id- Returns:
- child if found, null otherwise
-
getEntity
Find entity property based on givenpathwithin this property subtree. All rules of path design, are the same as described inget(String).- Implementation Requirements:
- might return null or throw exception. That depends on implementation.
- Parameters:
path- of entity property- Returns:
- found property
- See Also:
-
getCollection
Find collection property based on givenpathwithin this property subtree. All rules of path design, are the same as described inget(String).- Implementation Requirements:
- might return null or throw exception. That depends on implementation.
- Parameters:
path- of collection property- Returns:
- found property
- See Also:
-
getElementType
ElementType getElementType()Gets associated element type, based on property implementation.- Implementation Requirements:
- each implementation must be mapped to
ElementType. - Returns:
- property type
- See Also:
-
isEntity
default boolean isEntity()Is property an entity.- Implementation Requirements:
- The default implementation returns
false. Adequate subclasses should provide custom implementation. - Returns:
- true if property is entity type, false otherwise
- See Also:
-
isValue
default boolean isValue()Is property a value type.- Implementation Requirements:
- The default implementation returns
false. Adequate subclasses should provide custom implementation. - Returns:
- true if property is value type, false otherwise
- See Also:
-
isCollection
default boolean isCollection()Is property a collection type.- Implementation Requirements:
- The default implementation returns
false. Adequate subclasses should provide custom implementation. - Returns:
- true if property is collection type, false otherwise
- See Also:
-
isRoot
default boolean isRoot()Is property a root element.- Implementation Requirements:
- The default implementation returns
false.Adequate subclasses should provide custom implementation. - Returns:
- true if property is root element, false otherwise
- See Also:
-
asValue
ValueProperty asValue()- Returns:
- property as
ValueProperty
-
asEntity
EntityProperty asEntity()- Returns:
- property as
EntityProperty
-
asCollection
CollectionProperty asCollection()- Returns:
- property as
CollectionProperty
-
asRef
RefProperty asRef()- Returns:
- property as
RefProperty
-
traverse
This method walks on property subtree and invoke some action withPropertyVisitor. Think of it as Visitor Pattern.- Parameters:
visitor- property- See Also:
-
print
String print()Creates whole sub tree of this property as formatted String.- Returns:
- formatted String of subtree
-
add
Adds one or multiple properties to collection property, that exists under givenpath. The order of properties should be kept as they are provided. If there are properties added to collection property, which resides under this path, they should be added at the end. All rules of path design, are the same as described inget(String).- Implementation Requirements:
- each subclass should handle itself how it responds, if there is no element under path or is not collection property
- Parameters:
path- to collection propertyproperties- one or multiple properties that will be added- Returns:
- property under
path - See Also:
-
add
Adds one or multiple properties to collection property. The order of properties should be kept as they are provided. If there are properties added to collection property, which resides under this path, they should be added at the end.- Implementation Requirements:
- each subclass should handle itself how it responds
- Parameters:
properties- one or multiple properties that will be added- Returns:
thisproperty
-
remove
Removes property from givenpath. Property will first be detached from whole subtree, like collections and references. If that is possible, then property will be removed. All rules of path design, are the same as described inget(String).- Parameters:
path- points to property, that will be removed- Returns:
- removed property
- See Also:
-
remove
Property remove()Removes itself. Property will first be detached from whole subtree, like collections and references. If that is possible, then property will be removed.- Returns:
- removed property
-
clear
Property clear()Clear all children ofthisproperty.- Returns:
- itself
-
size
int size()- Returns:
- number of properties
-
at
Gets property at givenindexwithingthisproperty. Index starts with 0.- Implementation Requirements:
- should throw exception or return null, if
index > sizeof elements within property - Parameters:
index- of element within property- Returns:
- found property of index
-
create
Property create()- Implementation Requirements:
- each subclass should implement custom behaviour
- Returns:
- new property
-
has
Checks if this property has element of givenpath.- Implementation Requirements:
- By default, it returns
false - Parameters:
path- of element to be checked- Returns:
true, if property has element withpath,falseotherwise
-
isRef
default boolean isRef()Is property a reference type.- Implementation Requirements:
- The default implementation returns
false. - Returns:
- true if property is reference type,
falseotherwise
-
getRefTarget
Property getRefTarget()Gets property of reference's target.- Returns:
- reference's target. If property is reference type, it shouldn't return
null
-
getRefCount
int getRefCount()Number of nodes referencing target's property.- Returns:
- number of references
-
isPersistent
boolean isPersistent()Is property in persistent state.- Returns:
- true if property is in persistent state, false otherwise
-
isTransient
boolean isTransient()Is property in transient state.- Returns:
- true if property is in transient state, false otherwise
-
getState
EntityState getState()Gets state of property. There are two possible states of entity:EntityState.TRANSIENT- if property was just created and not yet marked for persistenceEntityState.PERSISTENT- if property was marked for persistence
- Returns:
- state of property
-
getHolder
Gets value of property wrapped intoValueHolderfrom givenpath. All rules of path design, are the same as described inget(String).- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Parameters:
path- to value- Returns:
- value of property wrapped into
ValueHolder - See Also:
-
getHolder
ValueHolder getHolder()- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Returns:
- value of property wrapped into
ValueHolder
-
getString
Gets value as String from givenpath. All rules of path design, are the same as described inget(String).- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Parameters:
path- to value- Returns:
- value of property as String
- See Also:
-
getString
String getString()- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Returns:
- value of property as String
-
getInteger
Gets value as Integer from givenpath. All rules of path design, are the same as described inget(String).- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Parameters:
path- to value- Returns:
- value of property as Integer
- See Also:
-
getInteger
Integer getInteger()- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Returns:
- value of property as Integer
-
getDecimal
Gets value as BigDecimal from givenpath. All rules of path design, are the same as described inget(String).- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Parameters:
path- to value- Returns:
- value of property as BigDecimal
- See Also:
-
getDecimal
BigDecimal getDecimal()- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Returns:
- value of property as BigDecimal
-
getLong
Gets value as Long from givenpath. All rules of path design, are the same as described inget(String).- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Parameters:
path- to value- Returns:
- value of property as Long
- See Also:
-
getLong
Long getLong()- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Returns:
- value of property as Long
-
getBoolean
Gets value as Boolean from givenpath. All rules of path design, are the same as described inget(String).- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Parameters:
path- to value- Returns:
- value of property as Boolean
- See Also:
-
getBoolean
Boolean getBoolean()- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Returns:
- value of property as Boolean
-
getDate
Gets value as Date from givenpath. All rules of path design, are the same as described inget(String).- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Parameters:
path- to value- Returns:
- value of property as Date
- See Also:
-
getDate
Date getDate()- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Returns:
- value of property as Date
-
getDatetime
Gets value as Date with time from givenpath. All rules of path design, are the same as described inget(String).- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Parameters:
path- to value- Returns:
- value of property as Date
- See Also:
-
getDatetime
Date getDatetime()- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Returns:
- value of property as Date with time
-
getNumber
Gets value as double from givenpath. All rules of path design, are the same as described inget(String).- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Parameters:
path- to value- Returns:
- value of property as double
- See Also:
-
getNumber
double getNumber()- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Returns:
- value of property as double
-
intValue
Gets value as int from givenpath. All rules of path design, are the same as described inget(String).- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Parameters:
path- to value- Returns:
- value of property as int
- See Also:
-
intValue
int intValue()- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Returns:
- value of property as int
-
booleanValue
Gets value as boolean from givenpath. All rules of path design, are the same as described inget(String).- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Parameters:
path- to value- Returns:
- value of property as boolean
- See Also:
-
booleanValue
boolean booleanValue()- Implementation Requirements:
- If not supported on subclasses, it should throw custom runtime exception.
- Returns:
- value of property as boolean
-