001/*
002 * GWTEventService
003 * Copyright (c) 2011 and beyond, strawbill UG (haftungsbeschr?nkt)
004 *
005 * This is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU Lesser General Public License as
007 * published by the Free Software Foundation; either version 3 of
008 * the License, or (at your option) any later version.
009 * Other licensing for GWTEventService may also be possible on request.
010 * Please view the license.txt of the project for more information.
011 *
012 * This software is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * You should have received a copy of the GNU Lesser General Public
018 * License along with this software; if not, write to the Free
019 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021 */
022package de.novanic.eventservice.client.event.filter;
023
024/**
025 * The EventFilterFactory can be used to connect various {@link de.novanic.eventservice.client.event.filter.EventFilter}
026 * instances by creating a {@link de.novanic.eventservice.client.event.filter.CompositeEventFilter}.
027 * A other solution to build filter sequences is available with {@link CascadingEventFilter} (cascading filter sequences).
028 *
029 * @author sstrohschein
030 *         <br>Date: 04.03.2009
031 *         <br>Time: 19:21:21
032 */
033public class EventFilterFactory
034{
035    /**
036     * The EventFilterFactory should be created via the getInstance method.
037     * @see EventFilterFactory#getInstance()
038     */
039    private EventFilterFactory() {}
040
041    /**
042     * Factory-Holder class to ensure thread-safe lazy-loading with IODH.
043     */
044    private static class EventFilterFactoryHolder {
045        private static final EventFilterFactory INSTANCE = new EventFilterFactory();
046    }
047
048    /**
049     * This method should be used to create an instance of EventFilterFactory.
050     * EventFilterFactory is a singleton, so this method returns always the same instance of
051     * EventFilterFactory.
052     * @return EventFilterFactory (singleton)
053     */
054    public static EventFilterFactory getInstance() {
055        return EventFilterFactoryHolder.INSTANCE;
056    }
057
058    /**
059     * That method can connect various {@link de.novanic.eventservice.client.event.filter.EventFilter} instances by
060     * building a {@link de.novanic.eventservice.client.event.filter.CompositeEventFilter}.
061     * @param anEventFilters {@link de.novanic.eventservice.client.event.filter.EventFilter} instances to build a
062     * {@link de.novanic.eventservice.client.event.filter.CompositeEventFilter}.
063     * @return {@link de.novanic.eventservice.client.event.filter.CompositeEventFilter} which contains the connectable
064     * {@link de.novanic.eventservice.client.event.filter.EventFilter} instances.
065     */
066    public CompositeEventFilter connect(EventFilter... anEventFilters) {
067        return new DefaultCompositeEventFilter(anEventFilters);
068    }
069}