src/core/net/sf/basedb/util/extensions/manager/PluginInfoKey.java

Code
Comments
Other
Rev Date Author Line
5615 19 Apr 11 nicklas 1 /**
5615 19 Apr 11 nicklas 2   $Id$
5615 19 Apr 11 nicklas 3
5615 19 Apr 11 nicklas 4   Copyright (C) 2011 Nicklas Nordborg
5615 19 Apr 11 nicklas 5
5615 19 Apr 11 nicklas 6   This file is part of BASE - BioArray Software Environment.
5615 19 Apr 11 nicklas 7   Available at http://base.thep.lu.se/
5615 19 Apr 11 nicklas 8
5615 19 Apr 11 nicklas 9   BASE is free software; you can redistribute it and/or
5615 19 Apr 11 nicklas 10   modify it under the terms of the GNU General Public License
5615 19 Apr 11 nicklas 11   as published by the Free Software Foundation; either version 3
5615 19 Apr 11 nicklas 12   of the License, or (at your option) any later version.
5615 19 Apr 11 nicklas 13
5615 19 Apr 11 nicklas 14   BASE is distributed in the hope that it will be useful,
5615 19 Apr 11 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
5615 19 Apr 11 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5615 19 Apr 11 nicklas 17   GNU General Public License for more details.
5615 19 Apr 11 nicklas 18
5615 19 Apr 11 nicklas 19   You should have received a copy of the GNU General Public License
5615 19 Apr 11 nicklas 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
5615 19 Apr 11 nicklas 21 */
5615 19 Apr 11 nicklas 22 package net.sf.basedb.util.extensions.manager;
5615 19 Apr 11 nicklas 23
5615 19 Apr 11 nicklas 24 import net.sf.basedb.util.extensions.xml.PluginInfo;
5615 19 Apr 11 nicklas 25
5615 19 Apr 11 nicklas 26 /**
5615 19 Apr 11 nicklas 27   Key implementation used to identify plug-in definitions.
5615 19 Apr 11 nicklas 28   Since a plug-in can be identified by it's class name,
5615 19 Apr 11 nicklas 29   we use that as the key for equality.
5615 19 Apr 11 nicklas 30
5615 19 Apr 11 nicklas 31   @author Nicklas
5615 19 Apr 11 nicklas 32   @since 3.0
5615 19 Apr 11 nicklas 33   @base.modified $Date$
5615 19 Apr 11 nicklas 34   @see PluginInfo
5615 19 Apr 11 nicklas 35 */
5615 19 Apr 11 nicklas 36 public class PluginInfoKey
5615 19 Apr 11 nicklas 37   implements ObjectKey<PluginInfo>
5615 19 Apr 11 nicklas 38 {
5615 19 Apr 11 nicklas 39   
5615 19 Apr 11 nicklas 40   private final String className;
5615 19 Apr 11 nicklas 41   
5615 19 Apr 11 nicklas 42   /**
5615 19 Apr 11 nicklas 43     Create a new key for a plug-in with the given class name.
5615 19 Apr 11 nicklas 44     @param className The class name (required)
5615 19 Apr 11 nicklas 45   */
5615 19 Apr 11 nicklas 46   public PluginInfoKey(String className)
5615 19 Apr 11 nicklas 47   {
5615 19 Apr 11 nicklas 48     if (className == null) throw new NullPointerException("className");
5615 19 Apr 11 nicklas 49     this.className = className;
5615 19 Apr 11 nicklas 50   }
5615 19 Apr 11 nicklas 51
5615 19 Apr 11 nicklas 52   /**
5691 11 Aug 11 nicklas 53     Create a new key for an plug-in definition.
5691 11 Aug 11 nicklas 54     @param info Information about the plug-in (required)
5615 19 Apr 11 nicklas 55   */
5615 19 Apr 11 nicklas 56   public PluginInfoKey(PluginInfo info)
5615 19 Apr 11 nicklas 57   {
5615 19 Apr 11 nicklas 58     this(info.getClassName());
5615 19 Apr 11 nicklas 59   }
5615 19 Apr 11 nicklas 60   
5615 19 Apr 11 nicklas 61   /*
5615 19 Apr 11 nicklas 62     From the ObjectKey interface
5615 19 Apr 11 nicklas 63     ----------------------------
5615 19 Apr 11 nicklas 64   */
5615 19 Apr 11 nicklas 65   @Override
5615 19 Apr 11 nicklas 66   public String toDescription()
5615 19 Apr 11 nicklas 67   {
5615 19 Apr 11 nicklas 68     return "Plugin '" + className + "'";
5615 19 Apr 11 nicklas 69   }
5615 19 Apr 11 nicklas 70   // -----------------------------
5615 19 Apr 11 nicklas 71   
5615 19 Apr 11 nicklas 72   /*
5615 19 Apr 11 nicklas 73     From the Object class
5615 19 Apr 11 nicklas 74     ---------------------
5615 19 Apr 11 nicklas 75   */
5615 19 Apr 11 nicklas 76   @Override
5615 19 Apr 11 nicklas 77   public int hashCode()
5615 19 Apr 11 nicklas 78   {
5615 19 Apr 11 nicklas 79     return className.hashCode();
5615 19 Apr 11 nicklas 80   }
5615 19 Apr 11 nicklas 81
5615 19 Apr 11 nicklas 82   @Override
5615 19 Apr 11 nicklas 83   public boolean equals(Object obj)
5615 19 Apr 11 nicklas 84   {
5615 19 Apr 11 nicklas 85     if (this == obj) return true;
5615 19 Apr 11 nicklas 86     if (obj == null || obj.getClass() != this.getClass()) return false;
5615 19 Apr 11 nicklas 87     PluginInfoKey other = (PluginInfoKey)obj;
5615 19 Apr 11 nicklas 88     return other.className.equals(this.className);
5615 19 Apr 11 nicklas 89   }
5615 19 Apr 11 nicklas 90
5615 19 Apr 11 nicklas 91   @Override
5615 19 Apr 11 nicklas 92   public String toString()
5615 19 Apr 11 nicklas 93   {
5615 19 Apr 11 nicklas 94     return "PluginInfoKey@" + System.identityHashCode(this) + "[" + className + "]";
5615 19 Apr 11 nicklas 95   }
5615 19 Apr 11 nicklas 96   // -----------------------
5615 19 Apr 11 nicklas 97   
5615 19 Apr 11 nicklas 98   
5615 19 Apr 11 nicklas 99 }