Class TestError
- java.lang.Object
-
- org.openstreetmap.josm.data.validation.TestError
-
- All Implemented Interfaces:
Comparable<TestError>
public class TestError extends Object implements Comparable<TestError>
Validation error- Since:
- 3669
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TestError.Builder
A builder for aTestError
.
-
Field Summary
Fields Modifier and Type Field Description private int
code
Internal code used by testers to classify errorsprivate String
description
Deeper error descriptionprivate String
descriptionEn
private Supplier<Command>
fixingCommand
Supplying a command to fix the errorprivate Collection<?>
highlighted
The primitives or way segments to be highlightedprivate boolean
ignored
is this error on the ignore listprivate String
message
The error messageprivate Collection<? extends OsmPrimitive>
primitives
The affected primitivesprivate boolean
selected
If this error is selectedprivate Severity
severity
Severityprivate Test
tester
The tester that raised this error
-
Constructor Summary
Constructors Constructor Description TestError(TestError.Builder builder)
-
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 newTestError
private boolean
calcIgnored()
int
compareTo(TestError o)
int
getCode()
Gets the codeString
getDescription()
Gets the error messageCommand
getFix()
Fixes the error with the appropriate commandCollection<?>
getHighlighted()
Returns The primitives or way segments to be highlightedprivate static List<List<Node>>
getHiliteNodesForArea(Area area)
Calculate list of node pairs describing the area.String
getIgnoreGroup()
Gets the ignore group ID that is used to allow the user to ignore all same errorsString
getIgnoreState()
Returns the ignore state for this error.String
getIgnoreSubGroup()
Gets the ignores subgroup that is more specialized thangetIgnoreGroup()
String
getMessage()
Gets the error messageMultipleNameVisitor
getNameVisitor()
Returns a newMultipleNameVisitor
for the list of primitives affected by this error.Collection<? extends OsmPrimitive>
getPrimitives()
Gets the list of primitives affected by this errorSeverity
getSeverity()
Gets the severity of this errorTest
getTester()
Gets the tester that raised this errorprivate static boolean
highlightedIsEqual(Collection<?> highlighted, Collection<?> highlighted2)
boolean
isFixable()
Returns true if the error can be fixed automaticallyboolean
isIgnored()
Checks if this error is ignoredboolean
isSelected()
Returns the selection flag of this errorboolean
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>
Stream<T>primitives(Class<T> type)
Gets all primitives of the given type affected by this errorvoid
setIgnored(boolean state)
Flags this error as ignoredvoid
setSelected(boolean selected)
Sets the selection flag of this errorString
toString()
boolean
updateIgnored()
Check if this error matches an entry in the ignore list and set the ignored flag if it is.void
visitHighlighted(ValidatorVisitor v)
Visits all highlighted validation elements
-
-
-
Field Detail
-
ignored
private boolean ignored
is this error on the ignore list
-
description
private final String description
Deeper error description
-
descriptionEn
private final String descriptionEn
-
primitives
private final Collection<? extends OsmPrimitive> primitives
The affected primitives
-
highlighted
private final Collection<?> highlighted
The primitives or way segments to be highlighted
-
code
private final int code
Internal code used by testers to classify errors
-
selected
private boolean selected
If this error is selected
-
fixingCommand
private final Supplier<Command> fixingCommand
Supplying a command to fix the error
-
-
Constructor Detail
-
TestError
TestError(TestError.Builder builder)
-
-
Method Detail
-
builder
public static TestError.Builder builder(Test tester, Severity severity, int code)
Starts building a newTestError
- Parameters:
tester
- The testerseverity
- The severity of this errorcode
- The test error reference code- Returns:
- a new test builder
- Since:
- 11129
-
getMessage
public String getMessage()
Gets the error message- Returns:
- the error message
-
getDescription
public String getDescription()
Gets the error message- Returns:
- the error description
-
getPrimitives
public Collection<? extends OsmPrimitive> getPrimitives()
Gets the list of primitives affected by this error- Returns:
- the list of primitives affected by this error
-
primitives
public final <T extends OsmPrimitive> Stream<T> primitives(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 String getIgnoreState()
Returns the ignore state for this error.- Returns:
- the ignore state for this error or null if any primitive is new
-
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
-
calcIgnored
private boolean calcIgnored()
-
getIgnoreSubGroup
public String getIgnoreSubGroup()
Gets the ignores subgroup that is more specialized thangetIgnoreGroup()
- Returns:
- The ignore sub group
-
getIgnoreGroup
public 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()
-
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
-
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 List<List<Node>> getHiliteNodesForArea(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 Collection<?> getHighlighted()
Returns The primitives or way segments to be highlighted- Returns:
- The primitives or way segments to be highlighted
- Since:
- 5671
-
compareTo
public int compareTo(TestError o)
- Specified by:
compareTo
in interfaceComparable<TestError>
-
getNameVisitor
public MultipleNameVisitor getNameVisitor()
Returns a newMultipleNameVisitor
for the list of primitives affected by this error.- Returns:
- Name visitor (used in cell renderer and for sorting)
-
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(Collection<?> highlighted, Collection<?> highlighted2)
-
-