20 package net.sf.gridarta.model.validation;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.Iterator;
30 import org.jetbrains.annotations.NotNull;
36 public class DelegatingMapValidator<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>,
SquareValidator<G, A, R>,
MapValidator<G, A, R>, Iterable<Validator<G, A, R>> {
42 private final Collection<Validator<G, A, R>>
validators =
new ArrayList<>();
64 super(validatorPreferences, key);
76 for (
final G archObject : mapSquare) {
78 for (
final G invObject : archObject.recursive()) {
83 mapModel.setErrors(errorCollector);
89 if (validator.isEnabled()) {
121 for (
final G gameObject : gameObjects) {
133 validators.add(validator);
139 return validators.iterator();
Iterator< Validator< G, A, R > > iterator()
A MapModel reflects the data of a map.
static final String DEFAULT_KEY
The default key.
This is the base class for validators.
Interface for GameObject Validators.
Interface for Map Validators.
DelegatingMapValidator(@NotNull final ValidatorPreferences validatorPreferences, @NotNull final String key)
Create a DelegatingMapValidator for a specific key.
void validateAll(@NotNull final MapModel< G, A, R > mapModel)
Perform all validations on a map.
Base package of all Gridarta classes.
void validateGameObject(@NotNull final G gameObject, @NotNull final ErrorCollector< G, A, R > errorCollector)
Reflects a game object (object on a map).
Configuration parameters for Validators.
GameObjects are the objects based on Archetypes found on maps.
final Collection< Validator< G, A, R > > validators
Map Validators to validate against.
DelegatingMapValidator(@NotNull final ValidatorPreferences validatorPreferences)
Create a DelegatingMapValidator for the default key.
void validateSquare(@NotNull final MapSquare< G, A, R > mapSquare, @NotNull final ErrorCollector< G, A, R > errorCollector)
A Map Validator that delegates to other MapValidators.
final ValidatorPreferences validatorPreferences
The ValidatorPreferences to use.
void validateMap(@NotNull final MapModel< G, A, R > mapModel, @NotNull final ErrorCollector< G, A, R > errorCollector)
void validate(@NotNull final G[] gameObjects, @NotNull final ErrorCollector< G, A, R > errorCollector)
Validate a set of game objects.
Simple error collector that just collects the error in a collection for later retrieval through itera...
Interface for MapArchObjects.
void addValidator(@NotNull final Validator< G, A, R > validator)
Add a Validator that might to be queried.
Interface for Square Validators.