5602 |
07 Apr 11 |
nicklas |
1 |
/** |
5602 |
07 Apr 11 |
nicklas |
$Id$ |
5602 |
07 Apr 11 |
nicklas |
3 |
|
5602 |
07 Apr 11 |
nicklas |
Copyright (C) 2011 Nicklas Nordborg |
5602 |
07 Apr 11 |
nicklas |
5 |
|
5602 |
07 Apr 11 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
5602 |
07 Apr 11 |
nicklas |
Available at http://base.thep.lu.se/ |
5602 |
07 Apr 11 |
nicklas |
8 |
|
5602 |
07 Apr 11 |
nicklas |
BASE is free software; you can redistribute it and/or |
5602 |
07 Apr 11 |
nicklas |
modify it under the terms of the GNU General Public License |
5602 |
07 Apr 11 |
nicklas |
as published by the Free Software Foundation; either version 3 |
5602 |
07 Apr 11 |
nicklas |
of the License, or (at your option) any later version. |
5602 |
07 Apr 11 |
nicklas |
13 |
|
5602 |
07 Apr 11 |
nicklas |
BASE is distributed in the hope that it will be useful, |
5602 |
07 Apr 11 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
5602 |
07 Apr 11 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5602 |
07 Apr 11 |
nicklas |
GNU General Public License for more details. |
5602 |
07 Apr 11 |
nicklas |
18 |
|
5602 |
07 Apr 11 |
nicklas |
You should have received a copy of the GNU General Public License |
5602 |
07 Apr 11 |
nicklas |
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.Extension; |
5602 |
07 Apr 11 |
nicklas |
25 |
|
5602 |
07 Apr 11 |
nicklas |
26 |
/** |
5602 |
07 Apr 11 |
nicklas |
Key implementation used to identify extensions. |
5602 |
07 Apr 11 |
nicklas |
Since each extension is identified by it's id, |
5602 |
07 Apr 11 |
nicklas |
we use that as the key for equality. |
5602 |
07 Apr 11 |
nicklas |
30 |
|
5602 |
07 Apr 11 |
nicklas |
@author Nicklas |
5602 |
07 Apr 11 |
nicklas |
@since 3.0 |
5602 |
07 Apr 11 |
nicklas |
@base.modified $Date$ |
5602 |
07 Apr 11 |
nicklas |
@see Extension |
5602 |
07 Apr 11 |
nicklas |
35 |
*/ |
5602 |
07 Apr 11 |
nicklas |
36 |
public class ExtensionKey |
6875 |
20 Apr 15 |
nicklas |
37 |
implements ObjectKey<Extension<?>> |
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 |
Create a new key for an extension with the given id. |
5602 |
07 Apr 11 |
nicklas |
@param id The id (required) |
5602 |
07 Apr 11 |
nicklas |
45 |
*/ |
5602 |
07 Apr 11 |
nicklas |
46 |
public ExtensionKey(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 |
Create a new key for an extension. |
5602 |
07 Apr 11 |
nicklas |
@param ext The extension point (required) |
5602 |
07 Apr 11 |
nicklas |
55 |
*/ |
6875 |
20 Apr 15 |
nicklas |
56 |
public ExtensionKey(Extension<?> ext) |
5602 |
07 Apr 11 |
nicklas |
57 |
{ |
5602 |
07 Apr 11 |
nicklas |
58 |
this(ext.getId()); |
5602 |
07 Apr 11 |
nicklas |
59 |
} |
5602 |
07 Apr 11 |
nicklas |
60 |
|
5602 |
07 Apr 11 |
nicklas |
61 |
/* |
5606 |
14 Apr 11 |
nicklas |
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 '" + 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 |
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 |
ExtensionKey other = (ExtensionKey)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 "ExtensionKey@" + 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 |
} |