Ignore:
Timestamp:
2016-03-05T17:57:04+01:00 (10 years ago)
Author:
simon04
Message:

see #8460 - fix typo from r9931, fix matching, improve conditions, add unit test

Location:
trunk/src/org/openstreetmap/josm/gui/tagging/presets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

    r9623 r9932  
    562562        else if (!typeMatches(t))
    563563            return false;
    564         boolean atLeastOnePositiveMatch = false;
    565         for (TaggingPresetItem item : data) {
    566             Boolean m = item.matches(tags);
    567             if (m != null && !m)
    568                 return false;
    569             else if (m != null) {
    570                 atLeastOnePositiveMatch = true;
    571             }
    572         }
    573         return atLeastOnePositiveMatch;
     564        else
     565            return TaggingPresetItem.matches(data, tags);
    574566    }
    575567
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java

    r9574 r9932  
    134134        return imgProv.get();
    135135    }
     136
     137    /**
     138     * Determine whether the given preset items match the tags
     139     * @param data the preset items
     140     * @param tags the tags to match
     141     * @return whether the given preset items match the tags
     142     * @sice 9932
     143     */
     144    public static boolean matches(Iterable<? extends TaggingPresetItem> data, Map<String, String> tags) {
     145        boolean atLeastOnePositiveMatch = false;
     146        for (TaggingPresetItem item : data) {
     147            Boolean m = item.matches(tags);
     148            if (m != null && !m)
     149                return false;
     150            else if (m != null) {
     151                atLeastOnePositiveMatch = true;
     152            }
     153        }
     154        return atLeastOnePositiveMatch;
     155    }
    136156}
Note: See TracChangeset for help on using the changeset viewer.