Changeset 17862 in josm for trunk/src/org/openstreetmap/josm/data/osm/FilterWorker.java
- Timestamp:
- 2021-05-06T17:39:27+02:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/FilterWorker.java
r12656 r17862 10 10 11 11 /** 12 * Class for applying {@link Filter}s to {@link OsmPrimitive}s.12 * Class for applying {@link Filter}s to {@link IPrimitive}s. 13 13 * 14 14 * Provides a bridge between Filter GUI and the data. … … 25 25 * Apply the filters to the primitives of the data set. 26 26 * 27 * @param <T> The primitive type 27 28 * @param all the collection of primitives for that the filter state should be updated 28 29 * @param filters the filters 29 30 * @return true, if the filter state (normal / disabled / hidden) of any primitive has changed in the process 30 31 * @throws SearchParseError if the search expression in a filter cannot be parsed 31 * @since 12383 32 * @since 12383, xxx (generics) 32 33 */ 33 public static boolean executeFilters(Collection<OsmPrimitive> all, Filter... filters) throws SearchParseError { 34 public static <T extends IPrimitive & IFilterablePrimitive> boolean executeFilters(Collection<T> all, Filter... filters) 35 throws SearchParseError { 34 36 return executeFilters(all, FilterMatcher.of(filters)); 35 37 } … … 38 40 * Apply the filters to the primitives of the data set. 39 41 * 42 * @param <T> The primitive type 40 43 * @param all the collection of primitives for that the filter state should be updated 41 44 * @param filterMatcher the FilterMatcher 42 45 * @return true, if the filter state (normal / disabled / hidden) of any primitive has changed in the process 46 * @since xxx (generics) 43 47 */ 44 public static boolean executeFilters(Collection<OsmPrimitive> all, FilterMatcher filterMatcher) {48 public static <T extends IPrimitive & IFilterablePrimitive> boolean executeFilters(Collection<T> all, FilterMatcher filterMatcher) { 45 49 boolean changed; 46 50 // first relations, then ways and nodes last; this is required to resolve dependencies 47 changed = doExecuteFilters(SubclassFilteredCollection.filter(all, Relation.class::isInstance), filterMatcher);48 changed |= doExecuteFilters(SubclassFilteredCollection.filter(all, Way.class::isInstance), filterMatcher);49 changed |= doExecuteFilters(SubclassFilteredCollection.filter(all, Node.class::isInstance), filterMatcher);51 changed = doExecuteFilters(SubclassFilteredCollection.filter(all, IRelation.class::isInstance), filterMatcher); 52 changed |= doExecuteFilters(SubclassFilteredCollection.filter(all, IWay.class::isInstance), filterMatcher); 53 changed |= doExecuteFilters(SubclassFilteredCollection.filter(all, INode.class::isInstance), filterMatcher); 50 54 return changed; 51 55 } 52 56 53 private static boolean doExecuteFilters(Collection<OsmPrimitive> all, FilterMatcher filterMatcher) {57 private static <T extends IPrimitive & IFilterablePrimitive> boolean doExecuteFilters(Collection<T> all, FilterMatcher filterMatcher) { 54 58 55 59 boolean changed = false; 56 60 57 for ( OsmPrimitive primitive: all) {61 for (T primitive : all) { 58 62 FilterType hiddenType = filterMatcher.isHidden(primitive); 59 63 if (hiddenType != FilterType.NOT_FILTERED) { … … 76 80 * Apply the filters to a single primitive. 77 81 * 82 * @param <T> the primitive type 78 83 * @param primitive the primitive 79 84 * @param filterMatcher the FilterMatcher 80 85 * @return true, if the filter state (normal / disabled / hidden) 81 86 * of the primitive has changed in the process 87 * @since xxx (generics) 82 88 */ 83 public static boolean executeFilters(OsmPrimitiveprimitive, FilterMatcher filterMatcher) {89 public static <T extends IPrimitive & IFilterablePrimitive> boolean executeFilters(T primitive, FilterMatcher filterMatcher) { 84 90 return doExecuteFilters(Collections.singleton(primitive), filterMatcher); 85 91 } … … 87 93 /** 88 94 * Clear all filter flags, i.e. turn off filters. 95 * @param <T> the primitive type 89 96 * @param prims the primitives 90 97 * @return true, if the filter state (normal / disabled / hidden) of any primitive has changed in the process 91 98 * @since 12388 (signature) 92 99 */ 93 public static boolean clearFilterFlags(Collection<OsmPrimitive> prims) {100 public static <T extends IPrimitive & IFilterablePrimitive> boolean clearFilterFlags(Collection<T> prims) { 94 101 boolean changed = false; 95 for ( OsmPrimitiveosm : prims) {102 for (T osm : prims) { 96 103 changed |= osm.unsetDisabledState(); 97 104 }
Note:
See TracChangeset
for help on using the changeset viewer.