Package io.higson.runtime.model.value
Class EntityProperty
java.lang.Object
io.higson.runtime.model.value.Property
io.higson.runtime.model.value.EntityProperty
- Direct Known Subclasses:
Bundle
This class represents property of entity (complex) type with fields. Each filed is stored as:
* key -> field name, which is case sensitive
* value -> another Property - subtype of {@link Property }
Basic API methods:
- Add property with field name -
add(String, Property) - Get property with field name -
getProp(String)
- Author:
- przemek hertel
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEntityProperty(long id, EntityType entityType) Creates entity (complex) property with id, based on givenentityType.EntityProperty(EntityType entityType) Creates entity (complex) property based on givenentityType. -
Method Summary
Modifier and TypeMethodDescriptionAdds givenpropertyunder providedname.booleancreate()deepcopy(boolean resetIds) Returns deep copy of this property's subtree.booleanfind(long id) Find child property by id.Gets associated element type, based on property implementation.longgetId()Gets property based on givenname.getState()Gets state of property.GetsValuePropertybased on givenname.booleanChecks if this property has element of givenpath.inthashCode()booleanisEntity()Is property an entity.voidmark()Marks entity property toEntityState.PERSISTENT.voidprint(StringBuilder sb, int level, String prefix, String suffix) Prints subtree to string builder.Creates formatted String.voidresetIds()Reset ids.voidSets newvalueof this property.void
children fields will also have their bundle setup.voidsetId(long id) Sets id.intsize()toString()Formatted String as follows:Methods inherited from class io.higson.runtime.model.value.Property
add, add, asCollection, asEntity, asRef, asValue, at, booleanValue, booleanValue, bundle, clear, 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, getString, getString, getType, getTypeCode, intValue, intValue, isCollection, isPersistent, isRoot, isTransient, isValue, iterator, print, remove, remove, set, setContainer, setName, setOwnerId, setParent, setupOwnerId, traverseMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
EntityProperty
Creates entity (complex) property based on givenentityType.- Parameters:
entityType- complex entity types- See Also:
-
EntityProperty
Creates entity (complex) property with id, based on givenentityType.- Parameters:
id- for propertyentityType- complex entity types- See Also:
-
-
Method Details
-
add
Adds givenpropertyunder providedname. Name is case sensitive. If there is already some property under this name, then newpropwill override previous property. If provided property isCollectionProperty, then all it's children will also have mapped parent to this.- Parameters:
name- unique nameprop- property to store under name- Returns:
- same
EntityPropertyinstance - See Also:
-
setBundle
children fields will also have their bundle setup. -
getFields
- Returns:
- property fields, where key is name of a field, and value is associated property
-
containsOnlyEntityFields
public boolean containsOnlyEntityFields()- Returns:
- true if all children fields are entities
-
getProp
Gets property based on givenname.- Parameters:
name- of field- Returns:
- property if found or null
- See Also:
-
getValue
GetsValuePropertybased on givenname. It may throw cast exception, if property of name is not type ofValueProperty.- Parameters:
name- of field- Returns:
- property if found or null
- See Also:
-
getId
public long getId() -
setId
public void setId(long id) Sets id.- Parameters:
id- for property
-
getElementType
Description copied from interface:HandleGets associated element type, based on property implementation.- Returns:
ElementType.ENTITYelement type- See Also:
-
isEntity
public boolean isEntity()Description copied from class:PropertyIs property an entity. -
deepcopy
Returns deep copy of this property's subtree.
It copies nested properties and reconstructs references to this property.- Specified by:
deepcopyin classProperty- Parameters:
resetIds- control flag, if true then property and all elements will have their id set to 0, if false, id will be copied- Returns:
- new instance of
EntityProperty - See Also:
-
resetIds
public void resetIds()Reset ids. Also it will reset ids of all children properties stored infields. -
print
Prints subtree to string builder. -
printValues
Creates formatted String. Example:EntityProperty[entityName#123, owner=44, values={field1=test}]- Returns:
- formatted String
-
size
public int size() -
create
Description copied from class:Property- Specified by:
createin interfaceHandle- Overrides:
createin classProperty- Returns:
- new instance of
EntityPropertybased onthiscompound type definition.
-
has
Checks if this property has element of givenpath.
This can check either direct field or nested children.- Parameters:
path- of element to be checked- Returns:
- true if found, false otherwise
-
set
Sets newvalueof this property..
It changes references and collection(container) properties with this new value or adds a new one. -
find
Find child property by id.- Parameters:
id- child id- Returns:
- child if found, null otherwise
-
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
-
mark
public void mark()Marks entity property toEntityState.PERSISTENT. -
equals
-
hashCode
public int hashCode() -
toString
Formatted String as follows:EntityProperty[name#23, @432423432, owner=101, fields=field1, refc=2]
-