Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java @ 8047:c835f3cf098e
Sediment load: Added join to fetch measurement station via ranges which know the river. Added a visitor for values, too.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 17 Jul 2014 11:19:59 +0200 |
parents | 86fa217c24d5 |
children | cde6d2a9ec32 |
comparison
equal
deleted
inserted
replaced
8046:8c14588d1f78 | 8047:c835f3cf098e |
---|---|
53 | 53 |
54 public interface Filter { | 54 public interface Filter { |
55 boolean accept(Value value); | 55 boolean accept(Value value); |
56 } | 56 } |
57 | 57 |
58 public interface Visitor { | |
59 void visit(Value value); | |
60 } | |
61 | |
58 private double value; | 62 private double value; |
59 | 63 |
60 private Load load; | 64 private Load load; |
61 | 65 |
62 public Value() { | 66 public Value() { |
238 public boolean hasGrainFraction(int grainFraction) { | 242 public boolean hasGrainFraction(int grainFraction) { |
239 List<Value> values = grainFractions.get(grainFraction); | 243 List<Value> values = grainFractions.get(grainFraction); |
240 return values != null && !values.isEmpty(); | 244 return values != null && !values.isEmpty(); |
241 } | 245 } |
242 | 246 |
247 public void filterGrainFraction( | |
248 int grainFraction, | |
249 Value.Filter filter, | |
250 Value.Visitor visitor | |
251 ) { | |
252 List<Value> values = grainFractions.get(grainFraction); | |
253 if (values != null && !values.isEmpty()) { | |
254 for (Value value: values) { | |
255 if (filter.accept(value)) { | |
256 visitor.visit(value); | |
257 } | |
258 } | |
259 } | |
260 } | |
261 | |
243 public List<Value> filterGrainFraction(int grainFraction, Value.Filter filter) { | 262 public List<Value> filterGrainFraction(int grainFraction, Value.Filter filter) { |
244 List<Value> values = grainFractions.get(grainFraction); | 263 final List<Value> result = new ArrayList<Value>(); |
245 if (values == null || values.isEmpty()) { | 264 filterGrainFraction(grainFraction, filter, new Value.Visitor() { |
246 return Collections.<Value>emptyList(); | 265 @Override |
247 } | 266 public void visit(Value value) { |
248 List<Value> result = new ArrayList<Value>(values.size()); | |
249 for (Value value: values) { | |
250 if (filter.accept(value)) { | |
251 result.add(value); | 267 result.add(value); |
252 } | 268 } |
253 } | 269 }); |
254 return result; | 270 return result; |
255 } | 271 } |
256 | 272 |
257 public double findValueByLoadId(int id) { | 273 public double findValueByLoadId(int id) { |
258 for (List<Value> values: grainFractions) { | 274 for (List<Value> values: grainFractions) { |