Class Attribute.OldValue

  • All Implemented Interfaces:
    AutoCloseable
    Enclosing class:
    Attribute<C,​T>

    public abstract static class Attribute.OldValue
    extends Object
    implements AutoCloseable
    A backup value from before attribute initialization, which must be closed to restore the old value. This is best used in try-with-resources.
    • Constructor Detail

      • OldValue

        protected OldValue​(Object oldValue)
    • Method Detail

      • getOldValue

        public Object getOldValue()
        Gets the old value of the attribute, which will be restored on close(). This can be of any type, since this is used to backup arbitrary values before new scopes.
        Returns:
        the old attribute value or null when none
      • close

        public abstract void close()
        Restores the old value of the attribute.
        Specified by:
        close in interface AutoCloseable