Package org.infinispan.commands.write
Enum ValueMatcher
- java.lang.Object
-
- java.lang.Enum<ValueMatcher>
-
- org.infinispan.commands.write.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 aputIfAbsent(k, v)
already succeeded on a backup owner which became the primary owner, when retrying the command will findv
in the cache but should returnnull
. For non-conditional commands it's impossible to know what the previous value was, so the command is allowed to returnv
.- Since:
- 6.0
- Author:
- Dan Berindei
-
-
Enum Constant Summary
Enum Constants Enum Constant Description MATCH_ALWAYS
Always match.MATCH_EXPECTED
Match when the existing value is equal to the expected value.MATCH_EXPECTED_OR_NEW
Match when the existing value is equal to the expected value or to the new value.MATCH_EXPECTED_OR_NULL
MATCH_NEVER
Never match.MATCH_NON_NULL
Match any non-null value.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract ValueMatcher
matcherForRetry()
abstract boolean
matches(Object existingValue, Object expectedValue, Object newValue)
abstract boolean
nonExistentEntryCanMatch()
Deprecated.Since 9.0, no longer used.static ValueMatcher
valueOf(int ordinal)
Returns the enum constant of this type with the specified name.static ValueMatcher
valueOf(String name)
Returns the enum constant of this type with the specified name.static ValueMatcher[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
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 retryingBasicCache.remove(Object)
operations.
-
MATCH_EXPECTED
public static final ValueMatcher MATCH_EXPECTED
Match when the existing value is equal to the expected value. Used forConcurrentMap.putIfAbsent(Object, Object)
,ConcurrentMap.replace(Object, Object, Object)
, andConcurrentMap.remove(Object, Object)
.
-
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_NON_NULL
public static final ValueMatcher MATCH_NON_NULL
Match any non-null value. Used forConcurrentMap.replace(Object, Object)
andBasicCache.remove(Object)
.
-
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 nameNullPointerException
- 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 nameNullPointerException
- if the argument is null
-
-