ExpirationAttributes (Apache Geode 1.15.4)

org.apache.geode.cache

## Class ExpirationAttributes

- java.lang.Object
- - org.apache.geode.cache.ExpirationAttributes

- All Implemented Interfaces:
    Serializable, DataSerializable

      public class ExpirationAttributes
      extends Object
      implements DataSerializable

  Immutable parameter object for accessing and setting the attributes associated with `timeToLive` and `idleTimeout`. If the expiration action is not specified, it defaults to `ExpirationAction.INVALIDATE`. If the timeout is not specified, it defaults to zero (which means to never timeout).
  Since:
    GemFire 3.0
  See Also:
    `AttributesFactory`, `RegionAttributes`, `AttributesMutator`, Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.geode.DataSerializable

      `DataSerializable.Replaceable`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ExpirationAttributes` | `DEFAULT` convenience constant for a default instance

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExpirationAttributes()` Constructs a default `ExpirationAttributes`, which indicates no expiration will take place.
    `ExpirationAttributes(int expirationTime)` Constructs an `ExpirationAttributes` with the specified expiration time and the default expiration action `ExpirationAction.INVALIDATE`.
    `ExpirationAttributes(int expirationTime, ExpirationAction expirationAction)` Constructs an `ExpirationAttributes` with the specified expiration time and expiration action.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static ExpirationAttributes` | `createFromData(DataInput in)`
    `boolean` | `equals(Object obj)`
    `void` | `fromData(DataInput in)` Reads the state of this object as primitive data from the given `DataInput`.
    `ExpirationAction` | `getAction()` Returns the action that should take place when this value or region expires.
    `int` | `getTimeout()` Returns the number of seconds before a region or value expires.
    `int` | `hashCode()`
    `boolean` | `isDefault()`
    `void` | `toData(DataOutput out)` Writes the state of this object as primitive data to the given `DataOutput`.
    `String` | `toString()` Returns a string representation of this `ExpirationAttributes`.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT

          @Immutable
          public static final ExpirationAttributes DEFAULT

      convenience constant for a default instance

  - ### Constructor Detail

    - #### ExpirationAttributes

          public ExpirationAttributes()

      Constructs a default `ExpirationAttributes`, which indicates no expiration will take place.

    - #### ExpirationAttributes

          public ExpirationAttributes(int expirationTime)

      Constructs an `ExpirationAttributes` with the specified expiration time and the default expiration action `ExpirationAction.INVALIDATE`.
      Parameters:
        `expirationTime` - The number of seconds before expiration
      Throws:
        `IllegalArgumentException` - if expirationTime is nonpositive

    - #### ExpirationAttributes

          public ExpirationAttributes(int expirationTime,
                                      ExpirationAction expirationAction)

      Constructs an `ExpirationAttributes` with the specified expiration time and expiration action.
      Parameters:
        `expirationTime` - The number of seconds for a value to live before it expires. If this parameter is negative, the expiration time will be set to 0, indicating no expiration.
        `expirationAction` - the action to take when the value expires

  - ### Method Detail

    - #### getTimeout

          public int getTimeout()

      Returns the number of seconds before a region or value expires.
      Returns:
        the relative number of seconds before a region or value expires or zero if it will never expire

    - #### getAction

          public ExpirationAction getAction()

      Returns the action that should take place when this value or region expires.
      Returns:
        the action to take when expiring

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Returns a string representation of this `ExpirationAttributes`. If the timeout is zero, returns `"NO EXPIRATION"`.
      Overrides:
        `toString` in class `Object`
      Returns:
        the String representation of this expiration attribute

    - #### createFromData

          public static ExpirationAttributes createFromData(DataInput in)
                                                     throws IOException,
                                                            ClassNotFoundException

      Throws:
        `IOException`
        `ClassNotFoundException`

    - #### fromData

          public void fromData(DataInput in)
                        throws IOException,
                               ClassNotFoundException

      Description copied from interface: `DataSerializable`
      Reads the state of this object as primitive data from the given `DataInput`.
      Specified by:
        `fromData` in interface `DataSerializable`
      Parameters:
        `in` - the `DataInput` to read from
      Throws:
        `IOException` - A problem occurs while reading from `in`
        `ClassNotFoundException` - A class could not be loaded while reading from `in`

    - #### toData

          public void toData(DataOutput out)
                      throws IOException

      Description copied from interface: `DataSerializable`
      Writes the state of this object as primitive data to the given `DataOutput`.

      Since 5.7 it is possible for any method call to the specified `DataOutput` to throw `GemFireRethrowable`. It should not be caught by user code. If it is it must be rethrown.

      Specified by:
        `toData` in interface `DataSerializable`
      Parameters:
        `out` - the `DataOutput` to write to
      Throws:
        `IOException` - A problem occurs while writing to `out`

    - #### isDefault

          public boolean isDefault()