|
| 1 | +package de.komoot.photon.query; |
| 2 | + |
| 3 | +import com.vividsolutions.jts.geom.Point; |
| 4 | + |
| 5 | +import java.util.HashMap; |
| 6 | +import java.util.HashSet; |
| 7 | +import java.util.Map; |
| 8 | +import java.util.Set; |
| 9 | + |
| 10 | +/** |
| 11 | + * A photon request that can hold filter parameters requested by client. |
| 12 | + * Created by Sachin Dole on 2/12/2015. |
| 13 | + */ |
| 14 | +public class FilteredPhotonRequest extends PhotonRequest { |
| 15 | + private Set<String> excludeKeys = new HashSet<String>(3); |
| 16 | + private Set<String> includeKeys = new HashSet<String>(3); |
| 17 | + private Set<String> excludeValues = new HashSet<String>(3); |
| 18 | + private Set<String> includeValues = new HashSet<String>(); |
| 19 | + private Map<String, Set<String>> includeTags = new HashMap<String, Set<String>>(3); |
| 20 | + private Map<String, Set<String>> excludeTags = new HashMap<String, Set<String>>(3); |
| 21 | + private Map<String, Set<String>> excludeTagValues = new HashMap<String, Set<String>>(3); |
| 22 | + FilteredPhotonRequest(String query, Integer limit, Point locationForBias, String language) { |
| 23 | + super(query, limit, locationForBias, language); |
| 24 | + } |
| 25 | + |
| 26 | + public Set<String> keys() { |
| 27 | + return includeKeys; |
| 28 | + } |
| 29 | + |
| 30 | + void keys(String includeKey) { |
| 31 | + this.includeKeys.add(includeKey); |
| 32 | + } |
| 33 | + |
| 34 | + public Set<String> values() { |
| 35 | + return includeValues; |
| 36 | + } |
| 37 | + |
| 38 | + void values(String keyToInclude) { |
| 39 | + includeValues.add(keyToInclude); |
| 40 | + } |
| 41 | + |
| 42 | + public Map<String, Set<String>> tags() { |
| 43 | + return includeTags; |
| 44 | + } |
| 45 | + |
| 46 | + void tags(String aKey, Set<String> manyValues) { |
| 47 | + this.includeTags.put(aKey, manyValues); |
| 48 | + } |
| 49 | + |
| 50 | + public Set<String> notValues() { |
| 51 | + return excludeValues; |
| 52 | + } |
| 53 | + |
| 54 | + public Map<String, Set<String>> notTags() { |
| 55 | + return excludeTags; |
| 56 | + } |
| 57 | + |
| 58 | + void notKeys(String excludeKey) { |
| 59 | + excludeKeys.add(excludeKey); |
| 60 | + } |
| 61 | + |
| 62 | + void notTags(String excludeKey, Set<String> excludeManyValues) { |
| 63 | + excludeTags.put(excludeKey, excludeManyValues); |
| 64 | + } |
| 65 | + |
| 66 | + void notValues(String excludeValue) { |
| 67 | + excludeValues.add(excludeValue); |
| 68 | + } |
| 69 | + |
| 70 | + public Set<String> notKeys() { |
| 71 | + return excludeKeys; |
| 72 | + } |
| 73 | + |
| 74 | + void tagNotValues(String key, Set<String> excludeValues) { |
| 75 | + excludeTagValues.put(key,excludeValues); |
| 76 | + } |
| 77 | + public Map<String,Set<String>> tagNotValues(){ |
| 78 | + return excludeTagValues; |
| 79 | + |
| 80 | + } |
| 81 | +} |
0 commit comments