Class ValidationError<G extends GameObject<G,​A,​R>,​A extends MapArchObject<A>,​R extends Archetype<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.Serializable
    Super 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 Detail

      • ValidationError

        protected ValidationError​(@NotNull
                                  @NotNull MapModel<G,​A,​R> mapModel)
                           throws java.lang.IllegalArgumentException
        Creates 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"
      • ValidationError

        protected ValidationError​(@NotNull
                                  @NotNull java.lang.String key,
                                  @NotNull
                                  @NotNull MapModel<G,​A,​R> mapModel)
        Creates a new instance.
        Parameters:
        key - Key
        mapModel - the map model that caused the error
    • 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 the MapSquares that caused the error.
        Returns:
        the map squares
      • addMapSquare

        protected void addMapSquare​(@NotNull
                                    @NotNull MapSquare<G,​A,​R> mapSquare)
        Adds an erroneous MapSquare.
        Parameters:
        mapSquare - the erroneous map square
      • getGameObjects

        @NotNull
        public @NotNull java.util.List<G> getGameObjects()
        Returns the GameObjects that caused the error.
        Returns:
        the game objects
      • addGameObject

        protected void addGameObject​(@NotNull
                                     G gameObject)
        Adds an erroneous GameObject.
        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:
        toString in class java.lang.Object