serial Version ID for HomGroup
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / RankClass.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.cdm.model.name;
12
13 import java.io.Serializable;
14 import java.util.Set;
15 import java.util.UUID;
16
17 import javax.xml.bind.annotation.XmlEnum;
18 import javax.xml.bind.annotation.XmlEnumValue;
19
20 import org.apache.log4j.Logger;
21
22 import eu.etaxonomy.cdm.model.common.EnumeratedTermVoc;
23 import eu.etaxonomy.cdm.model.common.IEnumTerm;
24 import eu.etaxonomy.cdm.model.common.Language;
25
26 /**
27 * The rank class defines the category of ranks a certain rank belongs to. This information is
28 * usually needed for correct formatting of taxon name text representations by using e.g.
29 * {@link Rank#isSupraGeneric()} . Prior to v3.3 this was computed by comparison of ranks.
30 * The current solution makes such methods less dependend on term loading.<BR>
31 * @see http://dev.e-taxonomy.eu/trac/ticket/3521
32 *
33 * @author a.mueller
34 * @created 11.06.2013
35 */
36 @XmlEnum
37 public enum RankClass implements IEnumTerm<RankClass>, Serializable{
38
39 //0
40 /**
41 * Unknown rank class is to be used if no information is available about the rank class.
42 * In the current model this type should never be used. However, it is a placeholder in case
43 * we find an appropriate usage in future and in case one needs a short term dummy.
44 */
45 @XmlEnumValue("Unknown")
46 @Deprecated Unknown(UUID.fromString("8c99ba63-2904-4dbb-87cb-3d3d7467e95d"), "Unknown rank class","UN", null),
47
48 //1
49 /**
50 * Class of ranks higher than {@link Rank#GENUS()}
51 */
52 @XmlEnumValue("Suprageneric")
53 Suprageneric(UUID.fromString("439a7897-9e0d-4560-b238-459d827f8a70"), "Suprageneric", "SG", null),
54
55 //2
56 /**
57 * Class of ranks equal to {@link Rank#GENUS()}. It is expected that there is only 1 such rank.
58 */
59 @XmlEnumValue("Genus")
60 Genus(UUID.fromString("86de25dc-3594-462f-a716-6d008caf2662"), "Genus", "GE", null),
61
62 //3
63 /**
64 * Class of ranks below {@link Rank#GENUS()} and above {@link Rank#SPECIES()}.
65 * This class includes {@link #SpeciesGroup species groups}
66 */
67 @XmlEnumValue("Infrageneric")
68 Infrageneric(UUID.fromString("37d5b535-3bf9-4749-af66-1a1c089dc0ae"), "Rank", "IG", null),
69
70 //4
71 /**
72 * Class of ranks directly above {@link Rank#SPECIES()} which are used to group certain species
73 * e.g. for better usability.
74 * This class is part of the {@link #Infrageneric} class but different nomenclatural rules are applied.
75 */
76 @XmlEnumValue("SpeciesGroup")
77 SpeciesGroup(UUID.fromString("702edcb7-ee53-45b7-8635-efcbbfd69bca"), "Species group or aggr.", "AG", Infrageneric),
78
79 //5
80 /**
81 * Class of ranks equal to {@link Rank#SPECIES()}. It is expected that there is only 1 such rank.
82 */
83 @XmlEnumValue("Species")
84 Species(UUID.fromString("74cc173b-788e-4b01-9d70-a988498458b7"), "Species", "SP", null),
85
86 //6
87 /**
88 * Class of ranks lower than {@link Rank#SPECIES()}
89 */
90 @XmlEnumValue("Infraspecific")
91 Infraspecific(UUID.fromString("25915b4c-7f07-442f-bdaa-9d0223f6be42"), "Infraspecific", "IS", null),
92
93 ;
94
95
96 @SuppressWarnings("unused")
97 private static final Logger logger = Logger.getLogger(RankClass.class);
98
99
100
101 private RankClass(UUID uuid, String defaultString, String key, RankClass parent){
102 delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, defaultString, key, parent);
103 }
104
105 // *************************** DELEGATE **************************************/
106
107 private static EnumeratedTermVoc<RankClass> delegateVoc;
108 private IEnumTerm<RankClass> delegateVocTerm;
109
110 static {
111 delegateVoc = EnumeratedTermVoc.getVoc(RankClass.class);
112 }
113
114 @Override
115 public String getKey(){return delegateVocTerm.getKey();}
116
117 @Override
118 public String getMessage(){return delegateVocTerm.getMessage();}
119
120 @Override
121 public String getMessage(Language language){return delegateVocTerm.getMessage(language);}
122
123 @Override
124 public UUID getUuid() {return delegateVocTerm.getUuid();}
125
126 @Override
127 public RankClass getKindOf() {return delegateVocTerm.getKindOf();}
128
129 @Override
130 public Set<RankClass> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
131
132 @Override
133 public boolean isKindOf(RankClass ancestor) {return delegateVocTerm.isKindOf(ancestor); }
134
135 @Override
136 public Set<RankClass> getGeneralizationOf(boolean recursive) {return delegateVocTerm.getGeneralizationOf(recursive);}
137
138
139
140 public static RankClass getByKey(String key){return delegateVoc.getByKey(key);}
141 public static RankClass getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
142
143
144 }