com.hazelcast.map.eviction

## Class RandomEvictionPolicy

- java.lang.Object
- - com.hazelcast.map.eviction.MapEvictionPolicy
  - - com.hazelcast.map.eviction.RandomEvictionPolicy

- All Implemented Interfaces:
    DataSerializable, IdentifiedDataSerializable, Comparator

      public class RandomEvictionPolicy
      extends MapEvictionPolicy
      implements IdentifiedDataSerializable

  Random eviction policy for an `IMap`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static RandomEvictionPolicy` | `INSTANCE` Random eviction policy instance.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RandomEvictionPolicy()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compare(EntryView entryView1, EntryView entryView2)`
    `boolean` | `equals(Object obj)`
    `int` | `getFactoryId()` Returns DataSerializableFactory factory ID for this class.
    `int` | `getId()` Returns type identifier for this class.
    `int` | `hashCode()`
    `void` | `readData(ObjectDataInput in)` Reads fields from the input stream
    `void` | `writeData(ObjectDataOutput out)` Writes object fields to output stream

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

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

    - ### Methods inherited from interface java.util.Comparator

      `comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

- - ### Field Detail

    - #### INSTANCE

          public static final RandomEvictionPolicy INSTANCE

      Random eviction policy instance.

  - ### Constructor Detail

    - #### RandomEvictionPolicy

          public RandomEvictionPolicy()

  - ### Method Detail

    - #### compare

          public int compare(EntryView entryView1,
                             EntryView entryView2)

      Description copied from class: `MapEvictionPolicy`

      If you prefer to evict the 1st entry then return negative number, if the 2nd entry is a better candidate then return a positive number or return 0 if both entries are equally good candidates for eviction

      Specified by:
        `compare` in class `MapEvictionPolicy`

    - #### getFactoryId

          public int getFactoryId()

      Description copied from interface: `IdentifiedDataSerializable`
      Returns DataSerializableFactory factory ID for this class.
      Specified by:
        `getFactoryId` in interface `IdentifiedDataSerializable`
      Returns:
        factory ID

    - #### getId

          public int getId()

      Description copied from interface: `IdentifiedDataSerializable`
      Returns type identifier for this class. It should be unique per DataSerializableFactory.
      Specified by:
        `getId` in interface `IdentifiedDataSerializable`
      Returns:
        type ID

    - #### writeData

          public void writeData(ObjectDataOutput out)
                         throws IOException

      Description copied from interface: `DataSerializable`
      Writes object fields to output stream
      Specified by:
        `writeData` in interface `DataSerializable`
      Parameters:
        `out` - output
      Throws:
        `IOException` - if an I/O error occurs. In particular, an `IOException` may be thrown if the output stream has been closed.

    - #### readData

          public void readData(ObjectDataInput in)
                        throws IOException

      Description copied from interface: `DataSerializable`
      Reads fields from the input stream
      Specified by:
        `readData` in interface `DataSerializable`
      Parameters:
        `in` - input
      Throws:
        `IOException` - if an I/O error occurs. In particular, an `IOException` may be thrown if the input stream has been closed.

    - #### equals

          public boolean equals(Object obj)

      Specified by:
        `equals` in interface `Comparator`
      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

Copyright © 2018. All rights reserved.