Enum ValueMatcher

  • All Implemented Interfaces:
    Serializable, Comparable<ValueMatcher>

    public enum ValueMatcher
    extends Enum<ValueMatcher>
    A policy for determining if a write command should be executed based on the current value in the cache. When retrying conditional write commands in non-transactional caches, it is also used to determine the appropriate return value. E.g. if a putIfAbsent(k, v) already succeeded on a backup owner which became the primary owner, when retrying the command will find v in the cache but should return null. For non-conditional commands it's impossible to know what the previous value was, so the command is allowed to return v.
    Since:
    6.0
    Author:
    Dan Berindei
    • Enum Constant Detail

      • MATCH_ALWAYS

        public static final ValueMatcher MATCH_ALWAYS
        Always match. Used when the command is not conditional or when the value was already checked (on the primary owner, in non-tx caches, or on the originator, in tx caches). Also used when retrying BasicCache.remove(Object) operations.
      • MATCH_EXPECTED_OR_NEW

        public static final ValueMatcher MATCH_EXPECTED_OR_NEW
        Match when the existing value is equal to the expected value or to the new value. Used only in non-tx caches, when retrying a conditional command on the primary owner.
      • MATCH_EXPECTED_OR_NULL

        public static final ValueMatcher MATCH_EXPECTED_OR_NULL
      • MATCH_NEVER

        public static final ValueMatcher MATCH_NEVER
        Never match. Only used in transactional mode, as unsuccessful commands are still sent remotely, even though they should not be performed.
    • Method Detail

      • values

        public static ValueMatcher[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (ValueMatcher c : ValueMatcher.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ValueMatcher valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • matches

        public abstract boolean matches​(Object existingValue,
                                        Object expectedValue,
                                        Object newValue)
      • nonExistentEntryCanMatch

        @Deprecated
        public abstract boolean nonExistentEntryCanMatch()
        Deprecated.
        Since 9.0, no longer used.
      • matcherForRetry

        public abstract ValueMatcher matcherForRetry()
      • valueOf

        public static ValueMatcher valueOf​(int ordinal)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        ordinal - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null