Package org.spongepowered.api.data
Interface KeyValueMatcher<V>
- Type Parameters:
V
- The value type
- All Superinterfaces:
DataSerializable
Represents a matcher for
Key
values.
This matcher can only be serialized if the underlying
value KeyValueMatcher
can also be serialized.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A builder to createKeyValueMatcher
s.static enum
Represents a operator to match the values of a key query. -
Method Summary
Modifier and TypeMethodDescriptionstatic KeyValueMatcher.Builder
<?> builder()
Constructs a newKeyValueMatcher.Builder
to createKeyValueMatcher
s.key()
Gets theKey
that is being used to match key and matcher values.boolean
Checks whether the given value is matched by this matcher.default boolean
matchesContainer
(ValueContainer valueContainer) Checks whether the value of theValueContainer
is matched by this matcher.static <V> KeyValueMatcher
<V> Creates aKeyValueMatcher
from the given key and value.static <V> KeyValueMatcher
<V> of
(Key<? extends Value<V>> key, V value, KeyValueMatcher.Operator operator) Creates aKeyValueMatcher
from the given key, value and operator.operator()
Gets the operator of the matcher.value()
Gets the value of the query.Methods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainer
-
Method Details
-
of
Creates aKeyValueMatcher
from the given key and value. The default operatorKeyValueMatcher.Operator.EQUAL
will be used.- Type Parameters:
V
- The value type- Parameters:
key
- The key of which the value should be matchedvalue
- The matcher value that key values will be matched against- Returns:
- The key value matcher
-
of
static <V> KeyValueMatcher<V> of(Key<? extends Value<V>> key, V value, KeyValueMatcher.Operator operator) Creates aKeyValueMatcher
from the given key, value and operator.- Type Parameters:
V
- The value type- Parameters:
key
- The key of which the value should be matchedvalue
- The matcher value that key values will be matched againstoperator
- The operator how the value should be matched- Returns:
- The key value matcher
-
builder
Constructs a newKeyValueMatcher.Builder
to createKeyValueMatcher
s.- Returns:
- The builder
-
key
Gets theKey
that is being used to match key and matcher values.- Returns:
- The key
-
operator
KeyValueMatcher.Operator operator()Gets the operator of the matcher.- Returns:
- The operator
-
value
Gets the value of the query. A empty optional represents the property not being present.- Returns:
- The value
-
matchesContainer
Checks whether the value of theValueContainer
is matched by this matcher.- Parameters:
valueContainer
- The value container to get the key value from- Returns:
- Whether this matcher matches the key value
-
matches
Checks whether the given value is matched by this matcher.- Parameters:
value
- The key value, a null value represents that the key doesn't exist- Returns:
- Whether this matcher matches the key value
-