public abstract class Property extends Object implements Handle
Most basic interactions are setting property - set(String, Object) and retrieving - get(String) it based on certain path.
For more, examine API here and all subclasses.
ValueProperty - represents property for simple(Java) types, like String, int, etc.EntityProperty - represents complex property with fieldsCollectionProperty - represents collection property, that can store many properties as a containerRefProperty - represents reference property, that points to other property
Some methods are only available for certain property types. For example, it is not possible to call at(int) on RefProperty,
but only on CollectionProperty.
So be aware of property type and it's supported functionality.
CollectionProperty,
ValueProperty,
RefProperty,
EntityProperty| Modifier and Type | Method and Description |
|---|---|
Property |
add(Property... properties)
Adds one or multiple properties to collection property.
|
Property |
add(String path,
Property... properties)
Adds one or multiple properties to collection property, that exists under given
path. |
CollectionProperty |
asCollection() |
EntityProperty |
asEntity() |
RefProperty |
asRef() |
ValueProperty |
asValue() |
Property |
at(int index)
Gets property at given
index withing this property. |
boolean |
booleanValue() |
boolean |
booleanValue(String path)
Gets value as boolean from given
path. |
Bundle |
bundle()
Same as
getBundle() |
Property |
clear()
Clear all children of
this property. |
Property |
create() |
Property |
deepcopy()
- creates deepcopy of this property
- resets all IDs and ownerIDs
|
abstract Property |
deepcopy(boolean resetIds)
Returns deep copy of this property's subtree.
|
boolean |
equals(Object o) |
Property |
get(String path)
Gets property under given
path. |
Boolean |
getBoolean() |
Boolean |
getBoolean(String path)
Gets value as Boolean from given
path. |
Bundle |
getBundle()
Gets bundle root.
|
String |
getCanonicalPath()
Returns canonical path for this element.
|
CollectionProperty |
getCollection(String path)
Find collection property based on given
path within this property subtree. |
Property |
getContainer() |
Date |
getDate() |
Date |
getDate(String path)
Gets value as Date from given
path. |
Date |
getDatetime() |
Date |
getDatetime(String path)
Gets value as Date with time from given
path. |
BigDecimal |
getDecimal() |
BigDecimal |
getDecimal(String path)
Gets value as BigDecimal from given
path. |
EntityProperty |
getEntity(String path)
Find entity property based on given
path within this property subtree. |
ValueHolder |
getHolder() |
ValueHolder |
getHolder(String path)
Gets value of property wrapped into
ValueHolder from given path. |
abstract long |
getId() |
Integer |
getInteger() |
Integer |
getInteger(String path)
Gets value as Integer from given
path. |
Long |
getLong() |
Long |
getLong(String path)
Gets value as Long from given
path. |
String |
getName()
Gets name or parent name, if name is not setup.
|
double |
getNumber() |
double |
getNumber(String path)
Gets value as double from given
path. |
long |
getOwnerId()
Gets owner (parent) id.
|
String |
getOwnerPropertyName()
Gets name or parent name, if name is not setup.
|
EntityProperty |
getParent()
Gets owning(parent) entity.
|
String |
getParentName()
Gets parent name or null if not setup.
|
String |
getPath()
Returns full path to this
property with . separator between elements names. |
int |
getRefCount()
Number of nodes referencing target's property.
|
Property |
getRefTarget()
Gets property of reference's target.
|
EntityState |
getState()
Gets state of property.
|
String |
getString() |
String |
getString(String path)
Gets value as String from given
path. |
TypeDef |
getType()
Gets type of this bundle property/element.
|
String |
getTypeCode()
Gets type's code from associated definition.
|
int |
hashCode() |
int |
intValue() |
int |
intValue(String path)
Gets value as int from given
path. |
boolean |
isCollection()
Is property a collection type.
|
boolean |
isEntity()
Is property an entity.
|
boolean |
isPersistent()
Is property in persistent state.
|
boolean |
isRoot()
Is property a root element.
|
boolean |
isTransient()
Is property in transient state.
|
boolean |
isValue()
Is property a value type.
|
Iterator<Property> |
iterator()
.
|
String |
print()
Creates whole sub tree of this property as formatted String.
|
abstract void |
print(StringBuilder sb,
int level,
String prefix,
String suffix)
Prints subtree to string builder.
|
Property |
remove()
Removes itself.
|
Property |
remove(String path)
Removes property from given
path. |
void |
resetIds()
Reset ids.
|
void |
set(Object value)
Sets new
value of this property. |
Property |
set(String path,
Object value)
Sets new
value under given path, which must exists. |
void |
setContainer(Property container)
Sets container for property.
|
void |
setName(String name)
Sets property name.
|
void |
setOwnerId(long ownerId)
Sets owner (parent) id.
|
void |
setParent(EntityProperty parent)
Sets parent(owner).
|
void |
setupOwnerId()
This method is similar to
setOwnerId(long), but id is fetched from parent. |
int |
size() |
void |
traverse(PropertyVisitor visitor)
This method walks on property subtree and invoke some action with
PropertyVisitor. |
void |
traverse(PropertyVisitor visitor,
boolean usePathsInVisitor)
This method walks on property subtree and invoke some action with
PropertyVisitor. |
getClass, notify, notifyAll, toString, wait, wait, waitfind, getElementType, has, isRefforEach, spliteratorpublic String getName()
getOwnerPropertyName()public String getParentName()
public String getOwnerPropertyName()
getName()public void setName(String name)
name - of propertypublic EntityProperty getParent()
public void setParent(EntityProperty parent)
parent - of propertypublic String getPath()
property with . separator between elements names.
- cart.policies
- cart.policies.variants.covers.premium
getCanonicalPath()public String getCanonicalPath()
- cart.policies[1]
- cart.policies[0].variants[2].covers[3].premium
getPath()public long getOwnerId()
public void setOwnerId(long ownerId)
ownerId - owner idpublic Property getContainer()
public void setContainer(Property container)
container - for propertypublic void setupOwnerId()
setOwnerId(long), but id is fetched from parent.
If parent is not setup, then ownerId will not be changed.public TypeDef getType()
public String getTypeCode()
public Bundle getBundle()
Bundlepublic Bundle bundle()
getBundle()Bundlepublic Property deepcopy()
public void resetIds()
public abstract long getId()
public abstract Property deepcopy(boolean resetIds)
resetIds - whether to reset ids on copydeepcopydeepcopy()public abstract void print(StringBuilder sb, int level, String prefix, String suffix)
sb - StringBuilder containing data to printlevel - level used to indentationprefix - value to used as prefixsuffix - value to used as suffixpublic Property get(String path)
path. There are few path resolving possibilities:
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")
If path is empty or null, property should return itself.get in interface Handlepath - should exists within this propertyHandle.set(String, Object)public ValueHolder getHolder(String path)
ValueHolder from given path.
All rules of path design, are the same as described in Handle.get(String).getHolder in interface Handlepath - to valueValueHolderHandle.get(String)public String getString(String path)
path.
All rules of path design, are the same as described in Handle.get(String).getString in interface Handlepath - to valueHandle.get(String)public Integer getInteger(String path)
path.
All rules of path design, are the same as described in Handle.get(String).getInteger in interface Handlepath - to valueHandle.get(String)public BigDecimal getDecimal(String path)
path.
All rules of path design, are the same as described in Handle.get(String).getDecimal in interface Handlepath - to valueHandle.get(String)public Long getLong(String path)
path.
All rules of path design, are the same as described in Handle.get(String).getLong in interface Handlepath - to valueHandle.get(String)public Boolean getBoolean(String path)
path.
All rules of path design, are the same as described in Handle.get(String).getBoolean in interface Handlepath - to valueHandle.get(String)public Date getDate(String path)
path.
All rules of path design, are the same as described in Handle.get(String).getDate in interface Handlepath - to valueHandle.get(String)public Date getDatetime(String path)
path.
All rules of path design, are the same as described in Handle.get(String).getDatetime in interface Handlepath - to valueHandle.get(String)public double getNumber(String path)
path.
All rules of path design, are the same as described in Handle.get(String).getNumber in interface Handlepath - to valueHandle.get(String)public int intValue(String path)
path.
All rules of path design, are the same as described in Handle.get(String).intValue in interface Handlepath - to valueHandle.get(String)public boolean booleanValue(String path)
path.
All rules of path design, are the same as described in Handle.get(String).booleanValue in interface Handlepath - to valueHandle.get(String)public Property set(String path, Object value)
value under given path, which must exists. All rules of path design, are the same as described in Handle.get(String).
Property agent = property.get("agent").set("age", 31).set("name", "steph");
This method is useful for setting up multiple properties of one parent property, in the sense of Builder Pattern.set in interface Handlepath - should exists within this propertyvalue - new value for path.Handle.get(String)public Property add(String path, Property... properties)
path.
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 in Handle.get(String).add in interface Handlepath - to collection propertyproperties - one or multiple properties that will be addedpathHandle.get(String)public Property remove(String path)
path.
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 in Handle.get(String).remove in interface Handlepath - points to property, that will be removedHandle.get(String)public String print()
public int getRefCount()
getRefCount in interface Handlepublic boolean isValue()
isValue in interface HandleValuePropertypublic boolean isEntity()
isEntity in interface HandleEntityPropertypublic boolean isCollection()
isCollection in interface HandleCollectionPropertypublic boolean isRoot()
public CollectionProperty asCollection()
asCollection in interface HandleCollectionPropertypublic RefProperty asRef()
asRef in interface HandleRefPropertypublic EntityProperty asEntity()
asEntity in interface HandleEntityPropertypublic ValueProperty asValue()
asValue in interface HandleValuePropertypublic Property create()
create in interface HandleHyperonPersistenceUsageException. Subclasses might provide different behaviour.public Property remove()
public void traverse(PropertyVisitor visitor)
PropertyVisitor. Think of it as Visitor Pattern.traverse in interface Handlevisitor - propertyPropertyVisitorpublic void traverse(PropertyVisitor visitor, boolean usePathsInVisitor)
PropertyVisitor. Think of it as Visitor Pattern.
Control flag usePathsInVisitor allows to switch between new and old way of resolving subtree. The outcome should be the same to the API user.
If set to true, the old way will be used. If set to false, the new mechanism will be used.traverse in interface Handlevisitor - propertyusePathsInVisitor - control flag if it should use paths to walk over subtreePropertyVisitorpublic String getString()
getString in interface HandleHyperonPersistenceUsageException.public Integer getInteger()
getInteger in interface HandleHyperonPersistenceUsageException.public BigDecimal getDecimal()
getDecimal in interface HandleHyperonPersistenceUsageException.public boolean booleanValue()
booleanValue in interface HandleHyperonPersistenceUsageException.public Boolean getBoolean()
getBoolean in interface HandleHyperonPersistenceUsageException.public Date getDate()
getDate in interface HandleHyperonPersistenceUsageException.public Date getDatetime()
getDatetime in interface HandleHyperonPersistenceUsageException.public ValueHolder getHolder()
getHolder in interface HandleHyperonPersistenceUsageException.ValueHolderpublic Long getLong()
getLong in interface HandleHyperonPersistenceUsageException.public double getNumber()
getNumber in interface HandleHyperonPersistenceUsageException.public int intValue()
intValue in interface HandleHyperonPersistenceUsageException.public void set(Object value)
value of this property.set in interface HandleHyperonPersistenceUsageException.value - new valuepublic Iterator<Property> iterator()
iterator in interface Iterable<Property>HyperonPersistenceUsageException. This is only supported by collection property type.public Property add(Property... properties)
public Property at(int index)
Handleindex withing this property.
Index starts with 0.public Property clear()
Handlethis property.public EntityProperty getEntity(String path)
path within this property subtree.
All rules of path design, are the same as described in Handle.get(String).getEntity in interface Handlepath - of entity propertyHyperonPersistenceUsageException - if element is not found or found but it is not instance of EntityPropertyHandle.get(String),
EntityPropertypublic CollectionProperty getCollection(String path)
path within this property subtree.
All rules of path design, are the same as described in Handle.get(String).getCollection in interface Handlepath - of collection propertyHyperonPersistenceUsageException - if element is not found or found but it is not instance of CollectionPropertyCollectionPropertypublic Property getRefTarget()
getRefTarget in interface Handlenullpublic EntityState getState()
EntityState.TRANSIENT - if property was just created and not yet marked for persistenceEntityState.PERSISTENT - if property was marked for persistence by BundleServicePersistenceMarker docs.getState in interface HandlePersistenceMarker,
BundleServicepublic boolean isPersistent()
isPersistent in interface HandleEntityState.PERSISTENTpublic boolean isTransient()
isTransient in interface HandleEntityState.TRANSIENTCopyright © 2021. All rights reserved.