Class ValidationError<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
- java.lang.Object
-
- net.sf.gridarta.model.validation.errors.ValidationError<G,A,R>
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
MapCheckerScriptIOError,MapValidationError
public abstract class ValidationError<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends java.lang.Object implements java.io.SerializableSuper class of all errors that could occur during map validation. The base methods of this class all return null and might return meaningful values if overridden in a subclass.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedValidationError(@NotNull java.lang.String key, @NotNull MapModel<G,A,R> mapModel)Creates a new instance.protectedValidationError(@NotNull MapModel<G,A,R> mapModel)Creates a new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddGameObject(G gameObject)Adds an erroneousGameObject.protected voidaddMapSquare(@NotNull MapSquare<G,A,R> mapSquare)Adds an erroneousMapSquare.@NotNull java.util.List<G>getGameObjects()Returns theGameObjectsthat caused the error.@NotNull MapModel<G,A,R>getMapModel()Return the map on which the error occurred.@NotNull java.lang.Iterable<MapSquare<G,A,R>>getMapSquares()Returns theMapSquaresthat caused the error.@NotNull java.lang.StringgetMessage()Returns the error message for this validation error.abstract @Nullable java.lang.StringgetParameter(int id)Returns a parameter string to be used in the error message.@Nullable java.lang.StringtoString()The String representation of an error is its title.
-
-
-
Constructor Detail
-
ValidationError
protected ValidationError(@NotNull @NotNull MapModel<G,A,R> mapModel) throws java.lang.IllegalArgumentExceptionCreates a new instance. The key is generated from the validator's name, which must end on "Checker".- Parameters:
mapModel- the map model that caused the error- Throws:
java.lang.IllegalArgumentException- in case the validator's name does not end on "Checker"
-
-
Method Detail
-
getMapModel
@NotNull public @NotNull MapModel<G,A,R> getMapModel()
Return the map on which the error occurred.- Returns:
- the erroneous map
-
getMapSquares
@NotNull public @NotNull java.lang.Iterable<MapSquare<G,A,R>> getMapSquares()
Returns theMapSquaresthat caused the error.- Returns:
- the map squares
-
addMapSquare
protected void addMapSquare(@NotNull @NotNull MapSquare<G,A,R> mapSquare)Adds an erroneousMapSquare.- Parameters:
mapSquare- the erroneous map square
-
getGameObjects
@NotNull public @NotNull java.util.List<G> getGameObjects()
Returns theGameObjectsthat caused the error.- Returns:
- the game objects
-
addGameObject
protected void addGameObject(@NotNull G gameObject)Adds an erroneousGameObject.- Parameters:
gameObject- the erroneous game object
-
getParameter
@Nullable public abstract @Nullable java.lang.String getParameter(int id)
Returns a parameter string to be used in the error message. It can be accessed with {4+id}.- Parameters:
id- the error id- Returns:
- the error string
-
getMessage
@NotNull public @NotNull java.lang.String getMessage()
Returns the error message for this validation error.- Returns:
- the error message for this validation error
- Todo:
- validation errors should be able to provide their own arguments for message formatting
-
toString
@Nullable public @Nullable java.lang.String toString()
The String representation of an error is its title.- Overrides:
toStringin classjava.lang.Object
-
-