20 package net.sf.gridarta.model.validation.checks;
22 import java.util.HashMap;
33 import org.jetbrains.annotations.NotNull;
39 public class CustomTypeChecker<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> {
47 private final Map<Integer, Map<Integer, Integer>>
ignoreEntries =
new HashMap<>();
59 final int archetypeTypeNo = gameObject.getArchetype().getTypeNo();
60 final int gameObjectTypeNo = gameObject.getTypeNo();
61 if (gameObjectTypeNo != archetypeTypeNo && !
isAllowedTypeChange(gameObject, archetypeTypeNo, gameObjectTypeNo)) {
62 errorCollector.collect(
new CustomTypeError<>(gameObject, archetypeTypeNo, gameObjectTypeNo));
74 final Map<Integer, Integer> entries =
ignoreEntries.get(archetypeTypeNo);
75 if (entries ==
null) {
79 final Integer allowedEnvType = entries.get(gameObjectTypeNo);
80 if (allowedEnvType ==
null) {
81 return entries.containsKey(gameObjectTypeNo);
85 if (envGameObject ==
null) {
89 final int envTypeNo = envGameObject.
getTypeNo();
90 return envTypeNo == allowedEnvType;
98 public void addIgnore(
final int fromType,
final int toType) {
108 public void addIgnore(
final int fromType,
final int toType,
final int envType) {
119 final Map<Integer, Integer> ignoreEntrySet =
ignoreEntries.get(type);
120 if (ignoreEntrySet !=
null) {
121 return ignoreEntrySet;
124 final Map<Integer, Integer> newIgnoreEntrySet =
new HashMap<>();
126 return newIgnoreEntrySet;