 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.model.validation.checks;
22 import java.util.Collection;
23 import java.util.HashMap;
24 import java.util.HashSet;
40 import org.jetbrains.annotations.NotNull;
47 public class ConnectionChecker<G
extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends
Archetype<G, A, R>> extends
AbstractValidator<G, A, R> implements
MapValidator<G, A, R> {
84 final Map<Integer, Rec> info =
new HashMap<>();
85 for (
final Iterable<G> mapSquare : mapModel) {
86 for (
final G gameObject : mapSquare) {
87 check(gameObject, info);
88 for (
final G invObject : gameObject.recursive()) {
89 check(invObject, info);
94 for (
final Map.Entry<Integer,
Rec> e : info.entrySet()) {
95 e.getValue().addErrors(e.getKey(), mapModel, errorCollector);
104 private void check(@NotNull
final G gameObject, @NotNull
final Map<Integer, Rec> info) {
106 if (values ==
null) {
110 for (
final int value : values) {
122 private Rec getRec(
final int value, @NotNull
final Map<Integer, Rec> info) {
123 final Rec existingRec = info.get(value);
124 if (existingRec !=
null) {
128 final Rec rec =
new Rec();
129 info.put(value, rec);
173 private final Collection<G>
unknowns =
new HashSet<>();
179 protected void add(@NotNull
final G gameObject) {
180 boolean isUnknown =
true;
202 for (
final G gameObject :
unknowns) {
final GameObjectMatcher sourceGameObjectMatcher
The GameObjectMatcher for matching sources.
A MapModel reflects the data of a map.
Manages information about one connection set.
static int[] parseConnections(@NotNull final BaseObject<?, ?, ?, ?> gameObject)
Extract the "connected" value(s) from a given game object.
void validateMap(@NotNull final MapModel< G, A, R > mapModel, @NotNull final ErrorCollector< G, A, R > errorCollector)
Validate a map.
Base package of all Gridarta classes.
Validation error for a connected object that is not supposed to be connected.
void addErrors(final int connection, @NotNull final MapModel< G, A, R > mapModel, @NotNull final ErrorCollector< G, A, R > errorCollector)
Creates validation errors for this connection set.
ConnectionChecker(@NotNull final ValidatorPreferences validatorPreferences, @NotNull final GameObjectMatcher sourceGameObjectMatcher, @NotNull final GameObjectMatcher sinkGameObjectMatcher, @NotNull final GameObjectMatcher sink2GameObjectMatcher)
Creates a new instance.
boolean isSource(@NotNull final GameObject<?, ?, ?> gameObject)
Returns whether a given game object is a source if connected.
Interface for classes that match GameObjects.
Reflects a game object (object on a map).
final GameObjectMatcher sink2GameObjectMatcher
The GameObjectMatcher for matching sinks.
final Collection< G > unknowns
The game objects in this connection set which are neither sources nor sinks.
final GameObjectMatcher sinkGameObjectMatcher
The GameObjectMatcher for matching sinks.
boolean isMatching(@NotNull GameObject<?, ?, ?> gameObject)
Matches a GameObject.
final Set< G > sinkGameObjects
The sink game objects in this connection set.
final ValidatorPreferences validatorPreferences
The ValidatorPreferences to use.
final Set< G > sourceGameObjects
The source game objects in this connection set.
Interface for Map Validators.
Configuration parameters for Validators.
GameObjects are the objects based on Archetypes found on maps.
Classes related to matching {GameObjects}, so called { net.sf.gridarta.model.match....
Rec getRec(final int value, @NotNull final Map< Integer, Rec > info)
Returns the record that describes a connection value.
Interface for MapArchObjects.
boolean isSink(@NotNull final GameObject< G, A, R > gameObject)
Returns whether a given game object is a sink if connected.
An interface for classes that collect errors.
This is the base class for validators.
Checks that for each connection value at least one source and at least one sink exists.
This package contains the framework for validating maps.
Validation error for a set of connected objects for which no sources exist.
Validation error for a set of connected objects for which no sinks exist.
void check(@NotNull final G gameObject, @NotNull final Map< Integer, Rec > info)
Processes a game object.
Utility class to parse "connected" fields in game objects.
void add(@NotNull final G gameObject)
Adds a game object to this connection set.