1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany |
---|
2 | // |
---|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
---|
4 | // you may not use this file except in compliance with the License. |
---|
5 | // You may obtain a copy of the License at |
---|
6 | // |
---|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
---|
8 | // |
---|
9 | // Unless required by applicable law or agreed to in writing, software |
---|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
---|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
12 | // See the License for the specific language governing permissions and |
---|
13 | // limitations under the License. |
---|
14 | |
---|
15 | package de.ugoe.cs.autoquest.plugin.usability2.rules.results; |
---|
16 | |
---|
17 | import java.util.Iterator; |
---|
18 | |
---|
19 | /** |
---|
20 | * <p> |
---|
21 | * TODO comment |
---|
22 | * </p> |
---|
23 | * |
---|
24 | * @author Konni Hartmann |
---|
25 | */ |
---|
26 | public abstract class TransformedResult implements IResult { |
---|
27 | |
---|
28 | final IResult result; |
---|
29 | |
---|
30 | public TransformedResult(IResult result) { |
---|
31 | this.result = result; |
---|
32 | } |
---|
33 | |
---|
34 | protected abstract IMatch transform(IMatch next); |
---|
35 | |
---|
36 | /* (non-Javadoc) |
---|
37 | * @see java.lang.Iterable#iterator() |
---|
38 | */ |
---|
39 | @Override |
---|
40 | public Iterator<IMatch> iterator() { |
---|
41 | return new Iterator<IMatch>() { |
---|
42 | Iterator<IMatch> inner = result.iterator(); |
---|
43 | |
---|
44 | @Override |
---|
45 | public boolean hasNext() { |
---|
46 | return inner.hasNext(); |
---|
47 | } |
---|
48 | |
---|
49 | @Override |
---|
50 | public IMatch next() { |
---|
51 | return transform(inner.next()); |
---|
52 | } |
---|
53 | |
---|
54 | @Override |
---|
55 | public void remove() { |
---|
56 | inner.remove(); |
---|
57 | } |
---|
58 | |
---|
59 | }; |
---|
60 | } |
---|
61 | |
---|
62 | /* (non-Javadoc) |
---|
63 | * @see de.ugoe.cs.autoquest.usability.rules.patterns.operator.IResult#isPresent() |
---|
64 | */ |
---|
65 | @Override |
---|
66 | public boolean isPresent() { |
---|
67 | return result.isPresent(); |
---|
68 | } |
---|
69 | |
---|
70 | } |
---|