Class RefProperty

java.lang.Object
io.higson.runtime.model.value.Property
io.higson.runtime.model.value.RefProperty
All Implemented Interfaces:
Handle, Iterable<Property>

public class RefProperty extends Property
This class represents reference (pointer) to real target Property. Created reference property acts as simple wrapper of target. All methods call on reference will actually invoke methods on target. Reference and target property are of the same type - TypeDef. What is also important, that reference property is equals to target property in the sense of equals and hashCode implementation.
Author:
przemek hertel
See Also:
  • Constructor Details

    • RefProperty

      public RefProperty(Property target)
      Creates reference property, which points to target Property. New created RefProperty will be of the same type, as passed target.
      Parameters:
      target - property, to which created reference property points
  • Method Details

    • getId

      public long getId()
      Specified by:
      getId in class Property
      Returns:
      target's id
    • deepcopy

      public Property deepcopy(boolean resetIds)
      Creates new instance of RefProperty with same target instance.
      Specified by:
      deepcopy in class Property
      Parameters:
      resetIds - this flag doesn't apply here
      Returns:
      new reference property instance
      See Also:
    • print

      public void print(StringBuilder sb, int level, String prefix, String suffix)
      Adds to sb formatted String, specific for RefProperty, which looks like:
      
        * [REF] cover1  (Cover#1003  @25658)
        - [REF] cover2  (Cover#1004  @95658)
       
      Specified by:
      print in class Property
      Parameters:
      sb - StringBuilder containing data to print
      level - level used to indentation
      prefix - value to used as prefix
      suffix - value to used as suffix
      See Also:
    • set

      public void set(Object value)
      Sets new value of this property.
      Here it means that this reference will be removed from property tree, and new value will be used instead.
      Specified by:
      set in interface Handle
      Overrides:
      set in class Property
      Parameters:
      value - new reference
    • isRef

      public boolean isRef()
      Is property a reference type.
      Returns:
      true
    • getRefTarget

      public Property getRefTarget()
      Gets property of reference's target.
      Specified by:
      getRefTarget in interface Handle
      Overrides:
      getRefTarget in class Property
      Returns:
      target property
    • getRefCount

      public int getRefCount()
      Number of nodes referencing target's property.
      Specified by:
      getRefCount in interface Handle
      Overrides:
      getRefCount in class Property
      Returns:
      number of references
    • find

      public Property find(long id)
      Find child property in the target.
      Parameters:
      id - child id
      Returns:
      property within target
    • has

      public boolean has(String path)
      Checks if target property has element of given path.
      Parameters:
      path - of element to be checked
      Returns:
      true if target has element, or false otherwise
    • asEntity

      public EntityProperty asEntity()
      Description copied from class: Property
      Specified by:
      asEntity in interface Handle
      Overrides:
      asEntity in class Property
      Returns:
      target as EntityProperty
    • getElementType

      public ElementType getElementType()
      Description copied from interface: Handle
      Gets associated element type, based on property implementation.
      Returns:
      ElementType.REF element type
      See Also:
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Property
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Property
    • toString

      public String toString()
      Custom String format:
      
         RefProperty[cart.policies, target=TypeCode#1234 @123456789]
       
      Overrides:
      toString in class Object
      Returns:
      formatted String