From 331f1aa40ea3acf4260b8a72083ec43a685cb287 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 11 Jan 2013 07:20:55 +0100 Subject: [PATCH] Add basic implementation of the watcher interface. --- .../rhynodge/watchers/DefaultWatcher.java | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 src/main/java/net/pterodactylus/rhynodge/watchers/DefaultWatcher.java diff --git a/src/main/java/net/pterodactylus/rhynodge/watchers/DefaultWatcher.java b/src/main/java/net/pterodactylus/rhynodge/watchers/DefaultWatcher.java new file mode 100644 index 0000000..fb6b218 --- /dev/null +++ b/src/main/java/net/pterodactylus/rhynodge/watchers/DefaultWatcher.java @@ -0,0 +1,88 @@ +/* + * Rhynodge - AbstractWatcher.java - Copyright © 2013 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.rhynodge.watchers; + +import java.util.ArrayList; +import java.util.List; + +import net.pterodactylus.rhynodge.Filter; +import net.pterodactylus.rhynodge.Query; +import net.pterodactylus.rhynodge.Trigger; +import net.pterodactylus.rhynodge.Watcher; + +/** + * Abstract base implementation of a {@link Watcher}. + * + * @author David ‘Bombe’ Roden + */ +public class DefaultWatcher implements Watcher { + + /** The query of the watcher. */ + private final Query query; + + /** The filters of the watcher. */ + private final List filters = new ArrayList(); + + /** The trigger of the watcher. */ + private final Trigger trigger; + + /** + * Creates a new default watcher. + * + * @param query + * The query of the watcher + * @param filters + * The filters of the watcher + * @param trigger + * The trigger of the watcher + */ + protected DefaultWatcher(Query query, List filters, Trigger trigger) { + this.query = query; + this.filters.addAll(filters); + this.trigger = trigger; + } + + // + // WATCHER METHODS + // + + /** + * {@inheritDoc} + */ + @Override + public Query query() { + return query; + } + + /** + * {@inheritDoc} + */ + @Override + public List filters() { + return filters; + } + + /** + * {@inheritDoc} + */ + @Override + public Trigger trigger() { + return trigger; + } + +} -- 2.7.4