Interface Handle

All Superinterfaces:
Iterable<Property>
All Known Implementing Classes:
Bundle, CollectionProperty, EntityProperty, Property, RefProperty, ValueProperty

public interface Handle extends Iterable<Property>
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 Details

    • get

      Property get(String path)
      Gets property under given 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.
      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

      Property set(String path, Object value)
      Sets new value under given path, which must exists. All rules of path design, are the same as described in get(String).
      Example:
      
        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.
      Implementation Requirements:
      new value might override previous value. It depends on exact implementation.
      Parameters:
      path - should exists within this property
      value - new value for path.
      Returns:
      same property instance.
      See Also:
    • set

      void set(Object value)
      Sets new value of this property.
      Implementation Requirements:
      specific behaviour may vary for each implementation.
      Parameters:
      value - new value
    • find

      default Property find(long id)
      Find child property by id.
      Implementation Requirements:
      default implementation will return null.
      Parameters:
      id - child id
      Returns:
      child if found, null otherwise
    • getEntity

      Property getEntity(String path)
      Find entity property based on given path within this property subtree. All rules of path design, are the same as described in get(String).
      Implementation Requirements:
      might return null or throw exception. That depends on implementation.
      Parameters:
      path - of entity property
      Returns:
      found property
      See Also:
    • getCollection

      CollectionProperty getCollection(String path)
      Find collection property based on given path within this property subtree. All rules of path design, are the same as described in get(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

      void traverse(PropertyVisitor visitor)
      This method walks on property subtree and invoke some action with PropertyVisitor. 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

      Property add(String path, Property... properties)
      Adds one or multiple properties to collection property, that exists under given 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 get(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 property
      properties - one or multiple properties that will be added
      Returns:
      property under path
      See Also:
    • add

      Property add(Property... properties)
      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:
      this property
    • remove

      Property remove(String path)
      Removes property from given 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 get(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 of this property.
      Returns:
      itself
    • size

      int size()
      Returns:
      number of properties
    • at

      Property at(int index)
      Gets property at given index withing this property. Index starts with 0.
      Implementation Requirements:
      should throw exception or return null, if index > size of 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

      default boolean has(String path)
      Checks if this property has element of given path.
      Implementation Requirements:
      By default, it returns false
      Parameters:
      path - of element to be checked
      Returns:
      true, if property has element with path, false otherwise
    • isRef

      default boolean isRef()
      Is property a reference type.
      Implementation Requirements:
      The default implementation returns false.
      Returns:
      true if property is reference type, false otherwise
    • 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:
      Returns:
      state of property
    • getHolder

      ValueHolder getHolder(String path)
      Gets value of property wrapped into ValueHolder from given path. All rules of path design, are the same as described in get(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

      String getString(String path)
      Gets value as String from given path. All rules of path design, are the same as described in get(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

      Integer getInteger(String path)
      Gets value as Integer from given path. All rules of path design, are the same as described in get(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

      BigDecimal getDecimal(String path)
      Gets value as BigDecimal from given path. All rules of path design, are the same as described in get(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

      Long getLong(String path)
      Gets value as Long from given path. All rules of path design, are the same as described in get(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

      Boolean getBoolean(String path)
      Gets value as Boolean from given path. All rules of path design, are the same as described in get(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

      Date getDate(String path)
      Gets value as Date from given path. All rules of path design, are the same as described in get(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

      Date getDatetime(String path)
      Gets value as Date with time from given path. All rules of path design, are the same as described in get(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

      double getNumber(String path)
      Gets value as double from given path. All rules of path design, are the same as described in get(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

      int intValue(String path)
      Gets value as int from given path. All rules of path design, are the same as described in get(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

      boolean booleanValue(String path)
      Gets value as boolean from given path. All rules of path design, are the same as described in get(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