001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.data.validation; 003 004import java.util.Collection; 005 006import org.openstreetmap.josm.command.Command; 007import org.openstreetmap.josm.data.osm.OsmPrimitive; 008 009/** 010 * Validation error easily fixable right at its detection. The fix can be given when constructing the error. 011 * @since 6377 012 */ 013public class FixableTestError extends TestError { 014 protected final Command fix; 015 016 /** 017 * Constructs a new {@code FixableTestError} for a single primitive. 018 * @param tester The tester 019 * @param severity The severity of this error 020 * @param message The error message 021 * @param code The test error reference code 022 * @param primitive The affected primitive 023 * @param fix The command used to fix the error 024 */ 025 public FixableTestError(Test tester, Severity severity, String message, int code, OsmPrimitive primitive, Command fix) { 026 super(tester, severity, message, code, primitive); 027 this.fix = fix; 028 } 029 030 /** 031 * Constructs a new {@code FixableTestError} for multiple primitives. 032 * @param tester The tester 033 * @param severity The severity of this error 034 * @param message The error message 035 * @param code The test error reference code 036 * @param primitives The affected primitives 037 * @param fix The command used to fix the error 038 */ 039 public FixableTestError(Test tester, Severity severity, String message, int code, Collection<? extends OsmPrimitive> primitives, 040 Command fix) { 041 super(tester, severity, message, code, primitives); 042 this.fix = fix; 043 } 044 045 /** 046 * Constructs a new {@code FixableTestError} for multiple primitives. 047 * @param tester The tester 048 * @param severity The severity of this error 049 * @param message The error message 050 * @param code The test error reference code 051 * @param primitives The affected primitives 052 * @param highlighted OSM primitives to highlight 053 * @param fix The command used to fix the error 054 */ 055 public FixableTestError(Test tester, Severity severity, String message, int code, Collection<? extends OsmPrimitive> primitives, 056 Collection<?> highlighted, Command fix) { 057 super(tester, severity, message, code, primitives, highlighted); 058 this.fix = fix; 059 } 060 061 /** 062 * Constructs a new {@code FixableTestError} for a single primitive. 063 * @param tester The tester 064 * @param severity The severity of this error 065 * @param message The error message 066 * @param description The translated description 067 * @param descriptionEn The English description 068 * @param code The test error reference code 069 * @param primitive The affected primitive 070 * @param fix The command used to fix the error 071 */ 072 public FixableTestError(Test tester, Severity severity, String message, String description, String descriptionEn, int code, 073 OsmPrimitive primitive, Command fix) { 074 super(tester, severity, message, description, descriptionEn, code, primitive); 075 this.fix = fix; 076 } 077 078 /** 079 * Constructs a new {@code FixableTestError} for multiple primitives. 080 * @param tester The tester 081 * @param severity The severity of this error 082 * @param message The error message 083 * @param description The translated description 084 * @param descriptionEn The English description 085 * @param code The test error reference code 086 * @param primitives The affected primitives 087 * @param fix The command used to fix the error 088 */ 089 public FixableTestError(Test tester, Severity severity, String message, String description, String descriptionEn, int code, 090 Collection<? extends OsmPrimitive> primitives, Command fix) { 091 super(tester, severity, message, description, descriptionEn, code, primitives); 092 this.fix = fix; 093 } 094 095 /** 096 * Constructs a new {@code FixableTestError} for multiple primitives. 097 * @param tester The tester 098 * @param severity The severity of this error 099 * @param message The error message 100 * @param description The translated description 101 * @param descriptionEn The English description 102 * @param code The test error reference code 103 * @param primitives The affected primitives 104 * @param highlighted OSM primitives to highlight 105 * @param fix The command used to fix the error 106 */ 107 public FixableTestError(Test tester, Severity severity, String message, String description, String descriptionEn, int code, 108 Collection<? extends OsmPrimitive> primitives, Collection<?> highlighted, Command fix) { 109 super(tester, severity, message, description, descriptionEn, code, primitives, highlighted); 110 this.fix = fix; 111 } 112 113 @Override 114 public Command getFix() { 115 return fix; 116 } 117 118 @Override 119 public final boolean isFixable() { 120 return true; 121 } 122}