Subject: [PATCH] #24075: KeyedItem precalculated match enum
---
Index: src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java b/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
--- a/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java	(revision 19280)
+++ b/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java	(date 1736507910846)
@@ -420,12 +420,12 @@
                 List<TaggingPresetItem> minData = new ArrayList<>();
                 for (TaggingPresetItem i : p.data) {
                     if (i instanceof KeyedItem) {
-                        if (!"none".equals(((KeyedItem) i).match))
+                        if (!"none".equals(((KeyedItem) i).match()))
                             minData.add(i);
                         addPresetValue((KeyedItem) i);
                     } else if (i instanceof CheckGroup) {
                         for (Check c : ((CheckGroup) i).checks) {
-                            if (!"none".equals(c.match))
+                            if (!"none".equals(c.match()))
                                 minData.add(c);
                             addPresetValue(c);
                         }
Index: src/org/openstreetmap/josm/gui/tagging/presets/items/KeyedItem.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/org/openstreetmap/josm/gui/tagging/presets/items/KeyedItem.java b/src/org/openstreetmap/josm/gui/tagging/presets/items/KeyedItem.java
--- a/src/org/openstreetmap/josm/gui/tagging/presets/items/KeyedItem.java	(revision 19280)
+++ b/src/org/openstreetmap/josm/gui/tagging/presets/items/KeyedItem.java	(date 1736508005010)
@@ -51,7 +51,7 @@
      * Note that for a match, at least one positive and no negative is required.
      * Default is "keyvalue!" for {@link Key} and "none" for {@link Text}, {@link Combo}, {@link MultiSelect} and {@link Check}.
      */
-    public String match = getDefaultMatch().getValue(); // NOSONAR
+    protected MatchType match = getDefaultMatch(); // NOSONAR
 
     /**
      * List of regions the preset is applicable for.
@@ -181,6 +181,33 @@
         }
     }
 
+    /**
+     * Allows to change the matching process, i.e., determining whether the tags of an OSM object fit into this preset.
+     * If a preset fits then it is linked in the Tags/Membership dialog.<ul>
+     * <li>none: neutral, i.e., do not consider this item for matching</li>
+     * <li>key: positive if key matches, neutral otherwise</li>
+     * <li>key!: positive if key matches, negative otherwise</li>
+     * <li>keyvalue: positive if key and value matches, neutral otherwise</li>
+     * <li>keyvalue!: positive if key and value matches, negative otherwise</li></ul>
+     * Note that for a match, at least one positive and no negative is required.
+     * Default is "keyvalue!" for {@link Key} and "none" for {@link Text}, {@link Combo}, {@link MultiSelect} and {@link Check}.
+     * @param match The match type. One of <code>none</code>, <code>key</code>, <code>key!</code>, <code>keyvalue</code>,
+     *              or <code>keyvalue!</code>.
+     * @since xxx
+     */
+    public void setMatch(String match) {
+        this.match = MatchType.ofString(match);
+    }
+
+    /**
+     * Get the match type for this item
+     * @return The match type
+     * @since xxx
+     */
+    public String match() {
+        return this.match.getValue();
+    }
+
     /**
      * Computes the tag usage for the given key from the given primitives
      * @param sel the primitives
@@ -221,7 +248,7 @@
      * @return whether key or key+value are required
      */
     public boolean isKeyRequired() {
-        final MatchType type = MatchType.ofString(match);
+        final MatchType type = this.match;
         return MatchType.KEY_REQUIRED == type || MatchType.KEY_VALUE_REQUIRED == type;
     }
 
@@ -243,7 +270,7 @@
 
     @Override
     public Boolean matches(Map<String, String> tags) {
-        switch (MatchType.ofString(match)) {
+        switch (this.match) {
         case NONE:
             return null; // NOSONAR
         case KEY:
