 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.model.validation.checks;
22 import java.util.HashMap;
23 import java.util.IdentityHashMap;
33 import org.jetbrains.annotations.NotNull;
39 public class AttributeRangeChecker<G
extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends
Archetype<G, A, R>> extends
AbstractValidator<G, A, R> implements
GameObjectValidator<G, A, R> {
45 private final Map<Integer, Type<G, A, R>>
types =
new HashMap<>();
51 private final Map<GameObjectMatcher, Type<G, A, R>>
matchers =
new IdentityHashMap<>();
71 public void add(
final int type, @NotNull
final String
name, @NotNull
final String displayName,
final int minValue,
final int maxValue)
throws InvalidCheckException {
72 if (minValue == Integer.MIN_VALUE && maxValue == Integer.MAX_VALUE) {
90 if (minValue == Integer.MIN_VALUE && maxValue == Integer.MAX_VALUE) {
105 if (oldType !=
null) {
110 types.put(type, newType);
122 if (oldType !=
null) {
133 if (!gameObject.isHead()) {
138 if (e.getKey().isMatching(gameObject)) {
139 e.getValue().validate(gameObject, errorCollector);
148 type.
validate(gameObject, errorCollector);
Base package of all Gridarta classes.
Manages all checks for one game object type.
An Exception indicating that an attribute check is invalid.
Type< G, A, R > getType(final int type)
Returns the Type instance for a given object type.
final Map< Integer, Type< G, A, R > > types
Maps object type to Type instance.
Interface for classes that match GameObjects.
Reflects a game object (object on a map).
final ValidatorPreferences validatorPreferences
The ValidatorPreferences to use.
Configuration parameters for Validators.
GameObjects are the objects based on Archetypes found on maps.
AttributeRangeChecker(@NotNull final ValidatorPreferences validatorPreferences)
Creates a new instance.
Classes related to matching {GameObjects}, so called { net.sf.gridarta.model.match....
Interface for MapArchObjects.
void validate(@NotNull final G gameObject, @NotNull final ErrorCollector< G, A, R > errorCollector)
Validate a game object.
An interface for classes that collect errors.
This is the base class for validators.
void add(@NotNull final GameObjectMatcher matcher, @NotNull final String name, @NotNull final String displayName, final int minValue, final int maxValue)
Adds an attribute to check.
This package contains the framework for validating maps.
Represents a range of attribute values.
void validateGameObject(@NotNull final G gameObject, @NotNull final ErrorCollector< G, A, R > errorCollector)
Validates a game object.
void add(final int type, @NotNull final String name, @NotNull final String displayName, final int minValue, final int maxValue)
Adds an attribute to check.
Interface for GameObject Validators.
A validator that checks for suspicious attribute values.
Type< G, A, R > getMatcher(@NotNull final GameObjectMatcher matcher)
Returns the Type instance for a given GameObjectMatcher.
final Map< GameObjectMatcher, Type< G, A, R > > matchers
Maps matcher to Type instance.