source: josm/trunk/src/org/openstreetmap/josm/data/validation/Severity.java@ 16626

Last change on this file since 16626 was 16626, checked in by simon04, 4 years ago

see #19334 - https://errorprone.info/bugpattern/ImmutableEnumChecker

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.validation;
3
4import static org.openstreetmap.josm.tools.I18n.marktr;
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.Color;
8
9import org.openstreetmap.josm.data.preferences.NamedColorProperty;
10import org.openstreetmap.josm.tools.Logging;
11
12/** The error severity */
13public enum Severity {
14 // CHECKSTYLE.OFF: SingleSpaceSeparator
15 /** Error messages */
16 ERROR(1, tr("Errors"), /* ICON(data/) */"error", new NamedColorProperty(marktr("validation error"), Color.RED).get()),
17 /** Warning messages */
18 WARNING(2, tr("Warnings"), /* ICON(data/) */"warning", new NamedColorProperty(marktr("validation warning"), Color.YELLOW).get()),
19 /** Other messages */
20 OTHER(3, tr("Other"), /* ICON(data/) */"other", new NamedColorProperty(marktr("validation other"), Color.CYAN).get());
21 // CHECKSTYLE.ON: SingleSpaceSeparator
22
23 /** Numeric ordering of the severities, 1 being major, 3 being minor */
24 private final int level;
25
26 /** Description of the severity code */
27 private final String message;
28
29 /** Associated icon */
30 private final String icon;
31
32 /** Associated color */
33 @SuppressWarnings("ImmutableEnumChecker") // see https://github.com/google/error-prone/pull/1682
34 private final Color color;
35
36 /**
37 * Constructor
38 *
39 * @param level Numeric ordering, 1 being major, 3 being minor
40 * @param message Description
41 * @param icon Associated icon
42 * @param color The color of this severity
43 */
44 Severity(int level, String message, String icon, Color color) {
45 this.level = level;
46 this.message = message;
47 this.icon = icon;
48 this.color = color;
49 }
50
51 /**
52 * Retrieves all colors once from the preferences to register them
53 */
54 public static void getColors() {
55 for (Severity c : values()) {
56 Logging.debug("{0}", c);
57 }
58 }
59
60 @Override
61 public String toString() {
62 return message;
63 }
64
65 /**
66 * Gets the associated icon
67 * @return the associated icon
68 */
69 public String getIcon() {
70 return icon;
71 }
72
73 /**
74 * Gets the associated color
75 * @return The associated color
76 */
77 public Color getColor() {
78 return color;
79 }
80
81 /**
82 * Gets the severity level, 1 being major, 3 being minor
83 * @return The severity level
84 * @since 12667
85 */
86 public int getLevel() {
87 return level;
88 }
89}
Note: See TracBrowser for help on using the repository browser.