Class ReferenceString

java.lang.Object
com.iizix.prop.ReferenceString
All Implemented Interfaces:
Cloneable

public class ReferenceString extends Object implements Cloneable
The reference string object that also can contain a custom reference object.
Author:
Christopher Mindus
  • Constructor Details

    • ReferenceString

      public ReferenceString(String s)
      Creates the String object.
  • Method Details

    • setObject

      public void setObject(Object o)
      Sets the Reference Object.
      Parameters:
      o - Any object or null for none.
    • getObject

      public Object getObject()
      Gets the Reference Object.
      Returns:
      The object set by setObject(Object).
    • clone

      public ReferenceString clone()
      Clones the reference string.
      Overrides:
      clone in class Object
      Returns:
      A cloned ReferenceString instance, with the SAME object reference as set by setObject(Object).
    • equalsOnlyReferenceString

      public boolean equalsOnlyReferenceString(ReferenceString rs)
      Checks if two reference strings are equal (excluding their object). This method is used to check comparisons when saving a file.
      Parameters:
      rs - The other reference string to compare with.
      Returns:
      true for equals, false otherwise.
    • equals

      public boolean equals(Object o)
      Checks if two reference strings are equal (including their object). This is required in order for the reference property to fire notification events.
      Overrides:
      equals in class Object
      Parameters:
      o - The object to compare with.
      Returns:
      true for equals, false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash code, consistent with equals(Object).

      Only the reference string takes part. Two instances that are equal always carry the same string, so the contract holds, and the mutable object set by setObject(Object) is deliberately left out so that the hash code of an instance already held in a hashed collection cannot change under it.

      Overrides:
      hashCode in class Object
      Returns:
      The hash code.
    • toString

      public String toString()
      Converts to a String.
      Overrides:
      toString in class Object
      Returns:
      The string reference.