Package io.higson.runtime.model.value
Class CollectionProperty
java.lang.Object
io.higson.runtime.model.value.Property
io.higson.runtime.model.value.CollectionProperty
This class represents collection of properties, that should store other properties with the same type
TypeDef.
All methods, which are accessing nested list, must follow this rule:
0 <= index < list.size().
Two collections of type CollectionProperty are equal in the sense of
equals and hashCode, if their nested list are equals.-
Constructor Summary
ConstructorsConstructorDescriptionCollectionProperty(EntityType entityType) CreatesCollectionPropertyfor provided compoundentityType.CollectionProperty(TypeDef type) CreatesCollectionPropertyfor providedtypedefinition. -
Method Summary
Modifier and TypeMethodDescriptionAttach givenpropertyat providedindex.Attach givenpropertyat providedindex.Attach givenpropertyat the end.Adds multiple properties in given order usingadd(Property).Attach givenpropertyat the end.at(int index) Gets property at givenindexwithingthisproperty.clear()Clear all children ofthisproperty.create()Creates new property ofEntityPropertywith compound type matching collection supported type.deepcopy(boolean resetIds) Creates defensive copies of collection property and it's property elements.booleanfind(long id) Search for element with id within collection and it's subtree.Gets associated element type, based on property implementation.longgetId()getList()inthashCode()booleanIs property a collection type.iterator().voidmark()Marks collection propertystatetoEntityState.PERSISTENT.voidprint(StringBuilder sb, int level, String prefix, String suffix) Adds tosbformatted String, specific forValueProperty, which looks like:voidresetIds()Resets owner id and reset ids on each property element fromlist.Attach givenpropertyat providedindex.voidvaluemust be of typeCollectionProperty, then all elements of this value will be added tothisCollectionPropertyinstance.intsize()Property[]toArray()Creates snapshot arraytoString()Formatted String as follows:Methods inherited from class io.higson.runtime.model.value.Property
add, asCollection, asEntity, asRef, asValue, booleanValue, booleanValue, bundle, deepcopy, get, getBoolean, getBoolean, getBundle, getCanonicalPath, getCollection, getContainer, getDate, getDate, getDatetime, getDatetime, getDecimal, getDecimal, getEntity, getHolder, getHolder, getInteger, getInteger, getLong, getLong, getName, getNumber, getNumber, getOwnerId, getOwnerPropertyName, getParent, getParentName, getPath, getRefCount, getRefTarget, getState, getString, getString, getType, getTypeCode, intValue, intValue, isEntity, isPersistent, isRoot, isTransient, isValue, print, remove, remove, set, setContainer, setName, setOwnerId, setParent, setupOwnerId, traverseMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
CollectionProperty
CreatesCollectionPropertyfor providedtypedefinition.- Parameters:
type- definition- See Also:
-
CollectionProperty
CreatesCollectionPropertyfor provided compoundentityType.- Parameters:
entityType- compound type
-
-
Method Details
-
add
Attach givenpropertyat the end. Check if givenpropertyis already in tree, then creates reference topropertyand adds it to collection.- Parameters:
property- to add- Returns:
- collection property on which this method is invoked
- See Also:
-
add
Attach givenpropertyat the end. Check if givenpropertyis already in tree andcheckRef == true, then creates reference topropertyand adds it to collection.- Parameters:
property- to addcheckRef- indicates whether add mechanism should check if given property is already in bundle. If yes, then ref property is created- Returns:
- collection property on which this method is invoked
-
add
Attach givenpropertyat providedindex. Check if givenpropertyis already in tree, then creates reference topropertyand adds it to collection.- Parameters:
index- in which given property should be addedproperty- to add- Returns:
- collection property on which this method is invoked
- See Also:
-
add
Attach givenpropertyat providedindex. Check if givenpropertyis already in tree andcheckRef == true, then creates reference topropertyand adds it to collection.- Parameters:
index- index in which given property should be addedproperty- to addcheckRef- indicates whether add mechanism should check if given property is already in bundle. If yes, then ref property is created- Returns:
- collection property on which this method is invoked
-
set
Attach givenpropertyat providedindex. Previous node will be removed from collections atindexposition.- Parameters:
index- index at which property should be replacedproperty- property to put atindex- Returns:
- collection property on which this method is invoked
- Throws:
IndexOutOfBoundsException- if index is greater then size of collection- See Also:
-
getList
- Returns:
- list of properties in kept order
-
mark
public void mark()Marks collection propertystatetoEntityState.PERSISTENT. -
add
Adds multiple properties in given order usingadd(Property). -
size
public int size() -
iterator
Description copied from class:Property. -
at
Gets property at givenindexwithingthisproperty. Index starts with 0.
Ifindexis smaller then 0 or exceeds list size, then exception will be throw.- Specified by:
atin interfaceHandle- Overrides:
atin classProperty- Parameters:
index- index to retrieve element from- Returns:
- property from collection
- Throws:
HigsonBundleUsageException- if index is not available for list
-
clear
Clear all children ofthisproperty.
Removes each element and all metadata behind. -
set
valuemust be of typeCollectionProperty, then all elements of this value will be added tothisCollectionPropertyinstance. Otherwise exception will be thrown.- Specified by:
setin interfaceHandle- Overrides:
setin classProperty- Parameters:
value- to be used- Throws:
HigsonBundleUsageException- ifvalueis not instance ofCollectionProperty
-
create
Creates new property ofEntityPropertywith compound type matching collection supported type. -
find
Search for element with id within collection and it's subtree.- Parameters:
id- child id- Returns:
- property if found or null
-
getElementType
Description copied from interface:HandleGets associated element type, based on property implementation.- Returns:
ElementType.COLLECTIONelement type- See Also:
-
deepcopy
Creates defensive copies of collection property and it's property elements. There is possibility to control id's of elements with givenresetIds.- Specified by:
deepcopyin classProperty- Parameters:
resetIds- whether to reset ids on copy- Returns:
- new instance of
CollectionProperty - See Also:
-
resetIds
public void resetIds()Resets owner id and reset ids on each property element fromlist. -
print
Adds tosbformatted String, specific forValueProperty, which looks like:* covers collection(Cover) size=2 * covers[0] (Cover#1003 @21133) refc=1 * code = CA (string) * premium = 100 (number) * su = 10000 (number) * covers[1] (Cover#1004 @45743) refc=1 * code = CB (string) * premium = 200 (number) * su = 20000 (number) -
equals
-
hashCode
public int hashCode() -
getId
public long getId() -
isCollection
public boolean isCollection()Description copied from class:PropertyIs property a collection type.- Specified by:
isCollectionin interfaceHandle- Overrides:
isCollectionin classProperty- Returns:
true- See Also:
-
toString
Formatted String as follows:CollectionProperty[collection1 (MyType) size=1] -
toArray
Creates snapshot array- Returns:
- array of properties
-