Class TestError

  • All Implemented Interfaces:
    java.lang.Comparable<TestError>

    public class TestError
    extends java.lang.Object
    implements java.lang.Comparable<TestError>
    Validation error
    Since:
    3669
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  TestError.Builder
      A builder for a TestError.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int code
      Internal code used by testers to classify errors
      private java.lang.String description
      Deeper error description
      private java.lang.String descriptionEn  
      private java.util.function.Supplier<Command> fixingCommand
      Supplying a command to fix the error
      private java.util.Collection<?> highlighted
      The primitives or way segments to be highlighted
      private boolean ignored
      is this error on the ignore list
      private boolean incompletePrimitives
      If all relevant primitives are known
      private java.lang.String message
      The error message
      private java.util.Collection<? extends OsmPrimitive> primitives
      The affected primitives
      private boolean selected
      If this error is selected
      private Severity severity
      Severity
      private static boolean switchOver
      Used to switch users over to new ignore system, UNIQUE_CODE_MESSAGE_STATE 1_704_067_200L → 2024-01-01 We can probably remove this and the supporting code in 2025.
      private Test tester
      The tester that raised this error
      private int uniqueCode
      Internal code used by testers to classify errors.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static TestError.Builder builder​(Test tester, Severity severity, int code)
      Starts building a new TestError
      private boolean calcIgnored()  
      int compareTo​(TestError o)  
      int getCode()
      Gets the code
      java.lang.String getDescription()
      Gets the error message
      Command getFix()
      Fixes the error with the appropriate command
      java.util.Collection<?> getHighlighted()
      Returns The primitives or way segments to be highlighted
      private static java.util.List<java.util.List<Node>> getHiliteNodesForArea​(java.awt.geom.Area area)
      Calculate list of node pairs describing the area.
      java.lang.String getIgnoreGroup()
      Gets the ignore group ID that is used to allow the user to ignore all same errors
      private java.lang.String getIgnoreGroup​(boolean useOriginal)
      Get the ignore group
      java.lang.String getIgnoreState()
      Returns the ignore state for this error.
      private java.lang.String getIgnoreState​(boolean useOriginal)
      Get the ignore state
      java.lang.String getIgnoreSubGroup()
      Gets the ignores subgroup that is more specialized than getIgnoreGroup()
      private java.lang.String getIgnoreSubGroup​(boolean useOriginal)
      Get the subgroup for the error
      java.lang.String getMessage()
      Gets the error message
      MultipleNameVisitor getNameVisitor()
      Returns a new MultipleNameVisitor for the list of primitives affected by this error.
      java.util.Collection<? extends OsmPrimitive> getPrimitives()
      Gets the list of primitives affected by this error
      Severity getSeverity()
      Gets the severity of this error
      Test getTester()
      Gets the tester that raised this error
      int getUniqueCode()
      Get the unique code for this test.
      private static boolean highlightedIsEqual​(java.util.Collection<?> highlighted, java.util.Collection<?> highlighted2)  
      boolean isConcerned​(java.util.Set<? extends OsmPrimitive> given)
      Check if any of the primitives in this error occurs in the given set of primitives.
      boolean isFixable()
      Returns true if the error can be fixed automatically
      boolean isIgnored()
      Checks if this error is ignored
      boolean isSelected()
      Returns the selection flag of this error
      boolean isSimilar​(TestError other)
      Tests if two errors are similar, i.e., same code and description and same combination of primitives and same combination of highlighted objects, but maybe with different orders.
      <T extends OsmPrimitive>
      java.util.stream.Stream<T>
      primitives​(java.lang.Class<T> type)
      Gets all primitives of the given type affected by this error
      void setIgnored​(boolean state)
      Flags this error as ignored
      void setSelected​(boolean selected)
      Sets the selection flag of this error
      (package private) static void setUpdateErrorCodes​(boolean updateErrorCodes)
      Update error codes on read and save.
      java.lang.String toString()  
      boolean updateIgnored()
      Check if this error matches an entry in the ignore list and set the ignored flag if it is.
      private static void updateIgnoreList​(java.lang.String oldKey, java.lang.String newKey)
      Convert old keys to new keys.
      void visitHighlighted​(ValidatorVisitor v)
      Visits all highlighted validation elements
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • switchOver

        private static boolean switchOver
        Used to switch users over to new ignore system, UNIQUE_CODE_MESSAGE_STATE 1_704_067_200L → 2024-01-01 We can probably remove this and the supporting code in 2025.
      • ignored

        private boolean ignored
        is this error on the ignore list
      • message

        private final java.lang.String message
        The error message
      • description

        private final java.lang.String description
        Deeper error description
      • highlighted

        private final java.util.Collection<?> highlighted
        The primitives or way segments to be highlighted
      • tester

        private final Test tester
        The tester that raised this error
      • code

        private final int code
        Internal code used by testers to classify errors
      • uniqueCode

        private final int uniqueCode
        Internal code used by testers to classify errors. Used for moving between JOSM versions.
      • selected

        private boolean selected
        If this error is selected
      • fixingCommand

        private final java.util.function.Supplier<Command> fixingCommand
        Supplying a command to fix the error
    • Method Detail

      • setUpdateErrorCodes

        static void setUpdateErrorCodes​(boolean updateErrorCodes)
        Update error codes on read and save. Used for tests.
        Parameters:
        updateErrorCodes - true to update error codes. See switchOver for default.
      • builder

        public static TestError.Builder builder​(Test tester,
                                                Severity severity,
                                                int code)
        Starts building a new TestError
        Parameters:
        tester - The tester
        severity - The severity of this error
        code - The test error reference code
        Returns:
        a new test builder
        Since:
        11129
      • getMessage

        public java.lang.String getMessage()
        Gets the error message
        Returns:
        the error message
      • getDescription

        public java.lang.String getDescription()
        Gets the error message
        Returns:
        the error description
      • getPrimitives

        public java.util.Collection<? extends OsmPrimitivegetPrimitives()
        Gets the list of primitives affected by this error
        Returns:
        the list of primitives affected by this error
      • primitives

        public final <T extends OsmPrimitive> java.util.stream.Stream<T> primitives​(java.lang.Class<T> type)
        Gets all primitives of the given type affected by this error
        Type Parameters:
        T - type of primitives
        Parameters:
        type - restrict primitives to subclasses
        Returns:
        the primitives as Stream
      • getSeverity

        public Severity getSeverity()
        Gets the severity of this error
        Returns:
        the severity of this error
      • getIgnoreState

        public java.lang.String getIgnoreState()
        Returns the ignore state for this error.
        Returns:
        the ignore state for this error or null if any primitive is new
      • getIgnoreState

        private java.lang.String getIgnoreState​(boolean useOriginal)
        Get the ignore state
        Parameters:
        useOriginal - if true, use the original code to get the ignore state
        Returns:
        The ignore state (getIgnoreGroup() + ignored object list)
      • updateIgnored

        public boolean updateIgnored()
        Check if this error matches an entry in the ignore list and set the ignored flag if it is.
        Returns:
        the new ignored state
      • updateIgnoreList

        private static void updateIgnoreList​(java.lang.String oldKey,
                                             java.lang.String newKey)
        Convert old keys to new keys. Only takes effect when switchOver is true
        Parameters:
        oldKey - The key to replace
        newKey - The new key
      • getIgnoreSubGroup

        public java.lang.String getIgnoreSubGroup()
        Gets the ignores subgroup that is more specialized than getIgnoreGroup()
        Returns:
        The ignore sub group
      • getIgnoreSubGroup

        private java.lang.String getIgnoreSubGroup​(boolean useOriginal)
        Get the subgroup for the error
        Parameters:
        useOriginal - if true, use the original code instead of the new unique codes.
        Returns:
        The ignore subgroup
      • getIgnoreGroup

        public java.lang.String getIgnoreGroup()
        Gets the ignore group ID that is used to allow the user to ignore all same errors
        Returns:
        The group id
        See Also:
        getIgnoreSubGroup()
      • getIgnoreGroup

        private java.lang.String getIgnoreGroup​(boolean useOriginal)
        Get the ignore group
        Parameters:
        useOriginal - if true, use the original code instead of a unique code + original code. Used for reading and understanding old ignore groups.
        Returns:
        The ignore group.
      • setIgnored

        public void setIgnored​(boolean state)
        Flags this error as ignored
        Parameters:
        state - The ignore flag
      • isIgnored

        public boolean isIgnored()
        Checks if this error is ignored
        Returns:
        true if it is ignored
      • getTester

        public Test getTester()
        Gets the tester that raised this error
        Returns:
        the tester that raised this error
      • getCode

        public int getCode()
        Gets the code
        Returns:
        the code
      • getUniqueCode

        public int getUniqueCode()
        Get the unique code for this test. Used for ignore lists.
        Returns:
        The unique code (generated with tester.getClass().getName().hashCode() + code).
        Since:
        18636
      • isFixable

        public boolean isFixable()
        Returns true if the error can be fixed automatically
        Returns:
        true if the error can be fixed
      • getFix

        public Command getFix()
        Fixes the error with the appropriate command
        Returns:
        The command to fix the error
      • setSelected

        public void setSelected​(boolean selected)
        Sets the selection flag of this error
        Parameters:
        selected - if this error is selected
      • visitHighlighted

        public void visitHighlighted​(ValidatorVisitor v)
        Visits all highlighted validation elements
        Parameters:
        v - The visitor that should receive a visit-notification on all highlighted elements
      • getHiliteNodesForArea

        private static java.util.List<java.util.List<Node>> getHiliteNodesForArea​(java.awt.geom.Area area)
        Calculate list of node pairs describing the area.
        Parameters:
        area - the area
        Returns:
        list of node pairs describing the area
      • isSelected

        public boolean isSelected()
        Returns the selection flag of this error
        Returns:
        true if this error is selected
        Since:
        5671
      • getHighlighted

        public java.util.Collection<?> getHighlighted()
        Returns The primitives or way segments to be highlighted
        Returns:
        The primitives or way segments to be highlighted
        Since:
        5671
      • isSimilar

        public boolean isSimilar​(TestError other)
        Tests if two errors are similar, i.e., same code and description and same combination of primitives and same combination of highlighted objects, but maybe with different orders.
        Parameters:
        other - the other error to be compared
        Returns:
        true if two errors are similar
      • highlightedIsEqual

        private static boolean highlightedIsEqual​(java.util.Collection<?> highlighted,
                                                  java.util.Collection<?> highlighted2)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isConcerned

        public boolean isConcerned​(java.util.Set<? extends OsmPrimitive> given)
        Check if any of the primitives in this error occurs in the given set of primitives.
        Parameters:
        given - the set of primitives
        Returns:
        true if any of the primitives in this error occurs in the given set of primitives, else false
        Since:
        18960