From: David ‘Bombe’ Roden Date: Fri, 11 Jan 2013 06:20:55 +0000 (+0100) Subject: Add basic implementation of the watcher interface. X-Git-Tag: 0.1~36 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=331f1aa40ea3acf4260b8a72083ec43a685cb287;p=rhynodge.git Add basic implementation of the watcher interface. --- 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; + } + +}