Changeset 35970 in osm for applications/editors/josm/plugins/utilsplugin2
- Timestamp:
- 2022-05-24T21:16:34+02:00 (3 years ago)
- Location:
- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/RangeMatch.java
r35436 r35970 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.utilsplugin2.search; 3 4 import java.util.Objects; 3 5 4 6 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 7 9 8 10 /** 11 * Matches objects with properties in a certain range. 9 12 * TODO: remove this copied class and make it public in JOSM core 10 13 */ 11 publicabstract class RangeMatch extends SearchCompiler.Match {14 abstract class RangeMatch extends SearchCompiler.Match { 12 15 13 16 private final long min; 14 17 private final long max; 15 18 16 publicRangeMatch(long min, long max) {19 RangeMatch(long min, long max) { 17 20 this.min = Math.min(min, max); 18 21 this.max = Math.max(min, max); 19 22 } 20 23 21 publicRangeMatch(PushbackTokenizer.Range range) {24 RangeMatch(PushbackTokenizer.Range range) { 22 25 this(range.getStart(), range.getEnd()); 23 26 } … … 38 41 @Override 39 42 public String toString() { 40 return getString() + "="+ min +"-"+ max;43 return getString() + '=' + min + '-' + max; 41 44 } 42 45 43 46 @Override 44 47 public int hashCode() { 45 final int prime = 31; 46 int result = 1; 47 result = prime * result + (int) (max ^ (max >>> 32)); 48 result = prime * result + (int) (min ^ (min >>> 32)); 49 return result; 48 return Objects.hash(max, min); 50 49 } 51 50 … … 57 56 return false; 58 57 RangeMatch other = (RangeMatch) obj; 59 if (max != other.max) 60 return false; 61 if (min != other.min) 62 return false; 63 return true; 58 return max == other.max 59 && min == other.min; 64 60 } 65 61 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/UtilsSimpleMatchFactory.java
r35436 r35970 2 2 package org.openstreetmap.josm.plugins.utilsplugin2.search; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 6 import java.util.Arrays; 5 7 import java.util.Collection; 8 import java.util.Collections; 6 9 7 10 import org.openstreetmap.josm.data.osm.search.PushbackTokenizer; … … 16 19 public class UtilsSimpleMatchFactory implements SimpleMatchFactory { 17 20 18 private static Collection<String> keywords = Arrays.asList("usedinways", "usedinrelations", "parents", "children"); 21 private static final Collection<String> keywords = 22 Collections.unmodifiableCollection(Arrays.asList("usedinways", "usedinrelations", "parents", "children")); 19 23 20 24 @Override … … 26 30 public SearchCompiler.Match get(String keyword, boolean caseSensitive, boolean regexSearch, PushbackTokenizer tokenizer) 27 31 throws SearchParseError { 28 if ("usedinways".equals(keyword)) { 32 if (tokenizer == null) { 33 throw new SearchParseError("<html>" + tr("Expecting {0} after {1}", "<code>:</code>", "<i>" + keyword + "</i>") + "</html>"); 34 } 35 switch (keyword) { 36 case "usedinways": 29 37 return new UsedInWaysMatch(tokenizer); 30 } else 31 if ("usedinrelations".equals(keyword)) { 32 return new UsedInRelationsMatch(tokenizer); 33 } else 34 if ("parents".equals(keyword)) { 35 return new ParentsMatch(tokenizer); 36 } else 37 if ("children".equals(keyword)) { 38 return new ChildrenMatch(tokenizer); 39 } else 40 return null; 38 case "usedinrelations": 39 return new UsedInRelationsMatch(tokenizer); 40 case "parents": 41 return new ParentsMatch(tokenizer); 42 case "children": 43 return new ChildrenMatch(tokenizer); 44 default: 45 throw new IllegalStateException("Not expecting keyword " + keyword); 46 } 41 47 } 42 48 }
Note:
See TracChangeset
for help on using the changeset viewer.