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

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