use of org.spongepowered.api.state.StateProperty in project SpongeCommon by SpongePowered.
the class AbstractSpongeStateMatcher method isValid.
protected final boolean isValid(final StateHolder<?, ?> stateHolder) {
for (final Map.Entry<StateProperty<@NonNull ?>, Object> entry : this.properties.entrySet()) {
final Property<?> property = (Property<?>) entry.getKey();
final Object value = stateHolder.getValues().get(property);
if (value == null || !value.equals(entry.getValue())) {
return false;
}
}
for (final StateProperty<@NonNull ?> entry : this.requiredProperties) {
final Property<?> property = (Property<?>) entry;
if (stateHolder.getValues().get(property) == null) {
return false;
}
}
final DataHolder dataHolder = (DataHolder) stateHolder;
for (final KeyValueMatcher<?> valueMatcher : this.keyValueMatchers) {
if (!this.matches(dataHolder, valueMatcher)) {
return false;
}
}
return true;
}
Aggregations