src/core/net/sf/basedb/util/overview/filter/ItemTypeFilter.java

Code
Comments
Other
Rev Date Author Line
4740 05 Feb 09 nicklas 1 /**
4740 05 Feb 09 nicklas 2   $Id$
4740 05 Feb 09 nicklas 3
4740 05 Feb 09 nicklas 4   Copyright (C) 2008 Nicklas Nordborg
4740 05 Feb 09 nicklas 5
4740 05 Feb 09 nicklas 6   This file is part of BASE - BioArray Software Environment.
4740 05 Feb 09 nicklas 7   Available at http://base.thep.lu.se/
4740 05 Feb 09 nicklas 8
4740 05 Feb 09 nicklas 9   BASE is free software; you can redistribute it and/or
4740 05 Feb 09 nicklas 10   modify it under the terms of the GNU General Public License
4740 05 Feb 09 nicklas 11   as published by the Free Software Foundation; either version 3
4740 05 Feb 09 nicklas 12   of the License, or (at your option) any later version.
4740 05 Feb 09 nicklas 13
4740 05 Feb 09 nicklas 14   BASE is distributed in the hope that it will be useful,
4740 05 Feb 09 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
4740 05 Feb 09 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4740 05 Feb 09 nicklas 17   GNU General Public License for more details.
4740 05 Feb 09 nicklas 18
4740 05 Feb 09 nicklas 19   You should have received a copy of the GNU General Public License
4740 05 Feb 09 nicklas 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
4740 05 Feb 09 nicklas 21 */
4740 05 Feb 09 nicklas 22 package net.sf.basedb.util.overview.filter;
4740 05 Feb 09 nicklas 23
4740 05 Feb 09 nicklas 24 import net.sf.basedb.core.Item;
4740 05 Feb 09 nicklas 25 import net.sf.basedb.util.filter.Filter;
4740 05 Feb 09 nicklas 26 import net.sf.basedb.util.overview.Node;
4740 05 Feb 09 nicklas 27
4740 05 Feb 09 nicklas 28 /**
4740 05 Feb 09 nicklas 29   A filter implementation that mathces item types on nodes.
4740 05 Feb 09 nicklas 30   It will evaluate to true for all {@link Node}:s whose
4740 05 Feb 09 nicklas 31   {@link Node#getItemType()} method matches the given item
4740 05 Feb 09 nicklas 32   type.
4740 05 Feb 09 nicklas 33
4740 05 Feb 09 nicklas 34   @author Nicklas
4740 05 Feb 09 nicklas 35   @version 2.10
4740 05 Feb 09 nicklas 36   @base.modified $Date$
4740 05 Feb 09 nicklas 37 */
4740 05 Feb 09 nicklas 38 public class ItemTypeFilter
4740 05 Feb 09 nicklas 39   implements Filter<Node>
4740 05 Feb 09 nicklas 40 {
4740 05 Feb 09 nicklas 41   
4740 05 Feb 09 nicklas 42   private final Item itemType;
4740 05 Feb 09 nicklas 43   
4740 05 Feb 09 nicklas 44   /**
4740 05 Feb 09 nicklas 45     Create a filter that finds nodes that has an attached item of the
4740 05 Feb 09 nicklas 46     given item type.
4740 05 Feb 09 nicklas 47     @param itemType The item type to look for
4740 05 Feb 09 nicklas 48   */
4740 05 Feb 09 nicklas 49   public ItemTypeFilter(Item itemType)
4740 05 Feb 09 nicklas 50   {
4740 05 Feb 09 nicklas 51     this.itemType = itemType;
4740 05 Feb 09 nicklas 52   }
4740 05 Feb 09 nicklas 53
4740 05 Feb 09 nicklas 54   /*
4740 05 Feb 09 nicklas 55     From the Filter interface
4740 05 Feb 09 nicklas 56     -------------------------
4740 05 Feb 09 nicklas 57   */
4740 05 Feb 09 nicklas 58   @Override
4740 05 Feb 09 nicklas 59   public boolean evaluate(Node node)
4740 05 Feb 09 nicklas 60   {
4740 05 Feb 09 nicklas 61     return node.getItemType() == itemType;
4740 05 Feb 09 nicklas 62   }
4740 05 Feb 09 nicklas 63   // -----------------------------
4740 05 Feb 09 nicklas 64 }