root/trunk/cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/NomenclaturalStatus.java

Revision 11066, 4.6 kB (checked in by a.mueller, 17 months ago)

Added clone() to all TaxonNameBase? classes (including some descriptive and common classes). #2170

  • Property svn:keywords set to Id
Line 
1/**
2* Copyright (C) 2007 EDIT
3* European Distributed Institute of Taxonomy
4* http://www.e-taxonomy.eu
5*
6* The contents of this file are subject to the Mozilla Public License Version 1.1
7* See LICENSE.TXT at the top of this package for the full license terms.
8*/
9
10package eu.etaxonomy.cdm.model.name;
11
12
13import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
14import eu.etaxonomy.cdm.model.reference.Reference;
15
16import org.apache.log4j.Logger;
17import org.hibernate.envers.Audited;
18
19import javax.persistence.*;
20import javax.xml.bind.annotation.XmlAccessType;
21import javax.xml.bind.annotation.XmlAccessorType;
22import javax.xml.bind.annotation.XmlElement;
23import javax.xml.bind.annotation.XmlIDREF;
24import javax.xml.bind.annotation.XmlSchemaType;
25import javax.xml.bind.annotation.XmlType;
26
27/**
28 * The class representing the assignation of a nomenclatural status to a
29 * {@link TaxonNameBase taxon name}. This includes a {@link NomenclaturalStatusType nomenclatural status type}
30 * (for instance "invalid", "novum" or "conserved") and eventually the article
31 * of the corresponding {@link NomenclaturalCode nomenclatural code} this status assignation is based on.
32 * One nomenclatural status can be assigned to several taxon names.
33 *
34 * @author m.doering
35 * @version 1.0
36 * @created 08-Nov-2007 13:06:39
37 */
38@XmlAccessorType(XmlAccessType.FIELD)
39@XmlType(name = "NomenclaturalStatus", propOrder = {
40    "ruleConsidered",
41    "type"
42})
43@Entity
44@Audited
45public class NomenclaturalStatus extends ReferencedEntityBase implements Cloneable{
46        private static final long serialVersionUID = -2451270405173131900L;
47        static Logger logger = Logger.getLogger(NomenclaturalStatus.class);
48       
49        //The nomenclatural code rule considered. The article/note/recommendation in the code in question that is commented on in
50        //the note property.
51        @XmlElement(name = "RuleConsidered")
52        private String ruleConsidered;
53       
54        @XmlElement(name = "NomenclaturalStatusType")
55    @XmlIDREF
56    @XmlSchemaType(name = "IDREF")
57    @ManyToOne(fetch = FetchType.LAZY)
58        private NomenclaturalStatusType type;
59
60        /**
61         * Class constructor: creates a new empty nomenclatural status instance.
62         */
63        protected NomenclaturalStatus() {
64                super();
65        }
66
67        /**
68         * Creates a new nomenclatural status instance with a given
69         * {@link NomenclaturalStatusType nomenclatural status type}.
70         *
71         * @see #NomenclaturalStatus()
72         */
73        public static NomenclaturalStatus NewInstance(NomenclaturalStatusType nomStatusType){
74                return NewInstance(nomStatusType, null, null);
75        }
76
77       
78        /**
79         * Creates a new nomenclatural status instance with a given
80         * {@link NomenclaturalStatusType nomenclatural status type}.
81         *
82         * @see #NomenclaturalStatus()
83         */
84        public static NomenclaturalStatus NewInstance(NomenclaturalStatusType nomStatusType, Reference citation, String microCitation){
85                NomenclaturalStatus status = new NomenclaturalStatus();
86                status.setType(nomStatusType);
87                status.setCitation(citation);
88                status.setCitationMicroReference(microCitation);
89                return status;
90        }
91       
92
93        /**
94         * Returns the {@link NomenclaturalStatusType nomenclatural status type} of <i>this</i>
95         * nomenclatural status.
96         */
97        public NomenclaturalStatusType getType(){
98                return this.type;
99        }
100
101        /**
102         * @see  #getType()
103         */
104        public void setType(NomenclaturalStatusType type){
105                this.type = type;
106        }
107
108        /**
109         * Returns the nomenclatural code rule considered (that is the
110         * article/note/recommendation in the nomenclatural code ruling
111         * the {@link TaxonNameBase#getNomenclaturalCode() taxon name(s)}) of <i>this</i>
112         * nomenclatural status. The considered rule gives the reason why the
113         * {@link NomenclaturalStatusType nomenclatural status type} has been
114         * assigned to the {@link TaxonNameBase taxon name(s)}.
115         */
116        public String getRuleConsidered(){
117                return this.ruleConsidered;
118        }
119
120        /**
121         * @see  #getRuleConsidered()
122         */
123        public void setRuleConsidered(String ruleConsidered){
124                this.ruleConsidered = ruleConsidered;
125        }
126       
127       
128//*********************** CLONE ********************************************************/
129       
130        /**
131         * Clones <i>this</i> nomenclatural status. This is a shortcut that enables to create
132         * a new instance that differs only slightly from <i>this</i> nomenclatural status by
133         * modifying only some of the attributes.
134         *
135         * @see eu.etaxonomy.cdm.model.common.ReferencedEntityBase#clone()
136         * @see java.lang.Object#clone()
137         */
138        @Override
139        public Object clone() {
140                try {
141                        NomenclaturalStatus result = (NomenclaturalStatus)super.clone();
142                        //no changes to: ruleConsidered, type
143                        return result;
144                } catch (CloneNotSupportedException e) {
145                        logger.warn("Object does not implement cloneable");
146                        e.printStackTrace();
147                        return null;
148                }
149        }       
150
151}
Note: See TracBrowser for help on using the browser.