Ignore:
Timestamp:
2016-01-02T18:51:06+01:00 (8 years ago)
Author:
simon04
Message:

Refactoring: move getMatchingPresets to TaggingPresets and add some Javadoc

File:
1 edited

Legend:

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

    r9231 r9266  
    296296    }
    297297
     298    /**
     299     * Determines whether a dialog can be shown for this preset, i.e., at least one tag can/must be set by the user.
     300     *
     301     * @return {@code true} if a dialog can be shown for this preset
     302     */
    298303    public boolean isShowable() {
    299304        for (TaggingPresetItem i : data) {
     
    503508    }
    504509
    505     @Override
     510    /**
     511     * Determines whether this preset matches the given primitive, i.e.,
     512     * whether the {@link #typeMatches(Collection) type matches} and the {@link TaggingPresetItem#matches(Map) tags match}.
     513     *
     514     * @param p the primitive
     515     * @return {@code true} if this preset matches the primitive
     516     */
     517     @Override
    506518    public boolean evaluate(OsmPrimitive p) {
    507519        return matches(EnumSet.of(TaggingPresetType.forPrimitive(p)), p.getKeys(), false);
    508520    }
    509521
     522    /**
     523     * Determines whether this preset matches the parameters.
     524     *
     525     * @param t the preset types to include, see {@link #typeMatches(Collection)}
     526     * @param tags the tags to perform matching on, see {@link TaggingPresetItem#matches(Map)}
     527     * @param onlyShowable whether the preset must be {@link #isShowable() showable}
     528     * @return {@code true} if this preset matches the parameters.
     529     */
    510530    public boolean matches(Collection<TaggingPresetType> t, Map<String, String> tags, boolean onlyShowable) {
    511531        if (onlyShowable && !isShowable())
     
    525545    }
    526546
    527     public static Collection<TaggingPreset> getMatchingPresets(final Collection<TaggingPresetType> t,
    528             final Map<String, String> tags, final boolean onlyShowable) {
    529         return Utils.filter(TaggingPresets.getTaggingPresets(), new Predicate<TaggingPreset>() {
    530             @Override
    531             public boolean evaluate(TaggingPreset object) {
    532                 return object.matches(t, tags, onlyShowable);
    533             }
    534         });
    535     }
    536 
    537547    /**
    538548     * Action that adds or removes the button on main toolbar
Note: See TracChangeset for help on using the changeset viewer.