Add basic implementation of the watcher interface.
[rhynodge.git] / src / main / java / net / pterodactylus / rhynodge / watchers / DefaultWatcher.java
1 /*
2  * Rhynodge - AbstractWatcher.java - Copyright © 2013 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.rhynodge.watchers;
19
20 import java.util.ArrayList;
21 import java.util.List;
22
23 import net.pterodactylus.rhynodge.Filter;
24 import net.pterodactylus.rhynodge.Query;
25 import net.pterodactylus.rhynodge.Trigger;
26 import net.pterodactylus.rhynodge.Watcher;
27
28 /**
29  * Abstract base implementation of a {@link Watcher}.
30  *
31  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
32  */
33 public class DefaultWatcher implements Watcher {
34
35         /** The query of the watcher. */
36         private final Query query;
37
38         /** The filters of the watcher. */
39         private final List<Filter> filters = new ArrayList<Filter>();
40
41         /** The trigger of the watcher. */
42         private final Trigger trigger;
43
44         /**
45          * Creates a new default watcher.
46          *
47          * @param query
48          *            The query of the watcher
49          * @param filters
50          *            The filters of the watcher
51          * @param trigger
52          *            The trigger of the watcher
53          */
54         protected DefaultWatcher(Query query, List<Filter> filters, Trigger trigger) {
55                 this.query = query;
56                 this.filters.addAll(filters);
57                 this.trigger = trigger;
58         }
59
60         //
61         // WATCHER METHODS
62         //
63
64         /**
65          * {@inheritDoc}
66          */
67         @Override
68         public Query query() {
69                 return query;
70         }
71
72         /**
73          * {@inheritDoc}
74          */
75         @Override
76         public List<Filter> filters() {
77                 return filters;
78         }
79
80         /**
81          * {@inheritDoc}
82          */
83         @Override
84         public Trigger trigger() {
85                 return trigger;
86         }
87
88 }