Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/model/FastAnnotations.java @ 8406:6ae0c5116d58
Distinguish between types of measurement stations and filter appropriately (plus minor cleanup in related classes).
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Tue, 14 Oct 2014 12:41:37 +0200 |
parents | 4c3ccf2b0304 |
children | 4809e23ffd27 |
comparison
equal
deleted
inserted
replaced
8405:a779ee47aa79 | 8406:6ae0c5116d58 |
---|---|
13 import java.util.List; | 13 import java.util.List; |
14 import java.util.Arrays; | 14 import java.util.Arrays; |
15 import java.util.HashMap; | 15 import java.util.HashMap; |
16 import java.util.Iterator; | 16 import java.util.Iterator; |
17 import java.util.NoSuchElementException; | 17 import java.util.NoSuchElementException; |
18 import java.util.regex.Pattern; | |
18 | 19 |
19 import java.io.Serializable; | 20 import java.io.Serializable; |
20 | 21 |
21 import org.hibernate.Session; | 22 import org.hibernate.Session; |
22 import org.hibernate.SQLQuery; | 23 import org.hibernate.SQLQuery; |
158 | 159 |
159 } // interface Filter | 160 } // interface Filter |
160 | 161 |
161 public static class NameFilter implements Filter { | 162 public static class NameFilter implements Filter { |
162 | 163 |
163 private String name; | 164 private Pattern namePattern; |
164 | 165 |
165 public NameFilter(String name) { | 166 public NameFilter(String name) { |
166 this.name = name; | 167 this.namePattern = Pattern.compile(name); |
167 } | 168 } |
168 | 169 |
169 @Override | 170 @Override |
170 public boolean accept(Annotation annotation) { | 171 public boolean accept(Annotation annotation) { |
171 return annotation.getName().contains(name); | 172 return namePattern.matcher(annotation.getName()).matches(); |
172 } | 173 } |
173 } // class NameFilter | 174 } // class NameFilter |
174 | 175 |
175 public static final Filter ALL = new Filter() { | 176 public static final Filter ALL = new Filter() { |
176 @Override | 177 @Override |