Class AbstractSurfaceObject.SurfaceObjectStateKey

  • All Implemented Interfaces:
    Cacheable
    Direct Known Subclasses:
    AbstractSurfaceShape.SurfaceShapeStateKey
    Enclosing class:
    AbstractSurfaceObject

    protected static class AbstractSurfaceObject.SurfaceObjectStateKey
    extends java.lang.Object
    implements Cacheable
    Represents a surface object's current state. StateKey uniquely identifies a surface object's current state as follows:
    • The StateKey class distinguishes the key from other object types.
    • The object's unique ID distinguishes one surface object instances from another.
    • The object's modified time distinguishes an object's internal state from any of its previous states.
    Using the unique ID to distinguish between objects ensures that the StateKey does not store dangling references to the surface object itself. Should the StateKey live longer than the surface object that created it, the StateKey does not prevent the object from being garbage collected.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected long modifiedTime
      The SurfaceObject's modified time.
      protected long uniqueId
      The SurfaceObject's unique ID.
    • Constructor Summary

      Constructors 
      Constructor Description
      SurfaceObjectStateKey​(long uniqueId, long modifiedTime)
      Constructs a new SurfaceObjectStateKey with the specified unique ID and modified time.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      long getSizeInBytes()
      Returns the state key's size in bytes.
      int hashCode()  
      • Methods inherited from class java.lang.Object

        clone, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • uniqueId

        protected final long uniqueId
        The SurfaceObject's unique ID. This is unique to all instances of SurfaceObject.
      • modifiedTime

        protected final long modifiedTime
        The SurfaceObject's modified time.
    • Constructor Detail

      • SurfaceObjectStateKey

        public SurfaceObjectStateKey​(long uniqueId,
                                     long modifiedTime)
        Constructs a new SurfaceObjectStateKey with the specified unique ID and modified time.
        Parameters:
        uniqueId - the SurfaceObject's unique ID.
        modifiedTime - the SurfaceObject's modified time.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getSizeInBytes

        public long getSizeInBytes()
        Returns the state key's size in bytes.
        Specified by:
        getSizeInBytes in interface Cacheable
        Returns:
        the state key's size in bytes.