improve to better fulfill the Comparator contract
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / BacterialName.java
index 3a1355cc9023628d93fe2ffa2c69c48a5ceef74a..6b747bd77ce2343aded49fb8c5a93ef5be72964e 100644 (file)
@@ -1,8 +1,8 @@
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
@@ -11,7 +11,6 @@ package eu.etaxonomy.cdm.model.name;
 
 
 import javax.persistence.Entity;
-import javax.persistence.Transient;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -19,12 +18,18 @@ import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
 import org.apache.log4j.Logger;
+import org.hibernate.envers.Audited;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Indexed;
+import org.springframework.beans.factory.annotation.Configurable;
+
+import eu.etaxonomy.cdm.strategy.cache.name.BacterialNameDefaultCacheStrategy;
 
 /**
  * The taxon name class for bacteria.
  * <P>
  * This class corresponds to: NameBacterial according to the ABCD schema.
- * 
+ *
  * @author m.doering
  * @version 1.0
  * @created 08-Nov-2007 13:06:11
@@ -36,33 +41,39 @@ import org.apache.log4j.Logger;
 })
 @XmlRootElement(name = "BacterialName")
 @Entity
-//@Audited
-public class BacterialName extends NonViralName {
-       
-       static Logger logger = Logger.getLogger(BacterialName.class);
+@Indexed(index = "eu.etaxonomy.cdm.model.name.TaxonNameBase")
+@Audited
+@Configurable
+public class BacterialName extends NonViralName<BacterialName> implements Cloneable{
+       private static final long serialVersionUID = -7641841279209976443L;
+       @SuppressWarnings("unused")
+       private static final Logger logger = Logger.getLogger(BacterialName.class);
 
        //Author team and year of the subgenus name
        @XmlElement(name = "SubGenusAuthorship")
+       @Field
        private String subGenusAuthorship;
-       
+
        //Approbation of name according to approved list, validation list, or validly published, paper in IJSB after 1980
        @XmlElement(name = "NameApprobation")
+       @Field
        private String nameApprobation;
 
        // ************* CONSTRUCTORS *************/
-       
+
        protected BacterialName(){
                super();
+               this.cacheStrategy = BacterialNameDefaultCacheStrategy.NewInstance();
        }
-       
-       /** 
+
+       /**
         * Class constructor: creates a new bacterial taxon name instance
         * only containing its {@link Rank rank},
         * its {@link HomotypicalGroup homotypical group} and
         * the {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy default cache strategy}.
         * The new bacterial taxon name instance will be also added to the set of
         * bacterial taxon names belonging to this homotypical group.
-        * 
+        *
         * @param       rank  the rank to be assigned to <i>this</i> bacterial taxon name
         * @param       homotypicalGroup  the homotypical group to which <i>this</i> bacterial taxon name belongs
         * @see         #NewInstance(Rank)
@@ -73,14 +84,15 @@ public class BacterialName extends NonViralName {
         */
        protected BacterialName(Rank rank, HomotypicalGroup homotypicalGroup) {
                super(rank, homotypicalGroup);
+               this.cacheStrategy = BacterialNameDefaultCacheStrategy.NewInstance();
        }
 
        //********* METHODS **************************************/
-       /** 
+       /**
         * Creates a new bacterial taxon name instance
-        * only containing its {@link Rank rank} and 
+        * only containing its {@link Rank rank} and
         * the {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy default cache strategy}.
-        * 
+        *
         * @param  rank  the rank to be assigned to <i>this</i> bacterial taxon name
         * @see    #NewInstance(Rank, HomotypicalGroup)
         * @see    #BacterialName(Rank, HomotypicalGroup)
@@ -92,14 +104,14 @@ public class BacterialName extends NonViralName {
                return new BacterialName(rank, null);
        }
 
-       /** 
+       /**
         * Creates a new bacterial taxon name instance
         * only containing its {@link Rank rank},
-        * its {@link HomotypicalGroup homotypical group} and 
+        * its {@link HomotypicalGroup homotypical group} and
         * the {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy default cache strategy}.
         * The new bacterial taxon name instance will be also added to the set of
         * bacterial taxon names belonging to this homotypical group.
-        * 
+        *
         * @param  rank  the rank to be assigned to <i>this</i> bacterial taxon name
         * @param  homotypicalGroup  the homotypical group to which <i>this</i> bacterial taxon name belongs
         * @see    #NewInstance(Rank)
@@ -111,15 +123,15 @@ public class BacterialName extends NonViralName {
        public static BacterialName NewInstance(Rank rank, HomotypicalGroup homotypicalGroup){
                return new BacterialName(rank, homotypicalGroup);
        }
-       
+
        /**
         * Returns the string containing the authorship with the year and details
         * of the reference in which the subgenus included in the scientific name
         * of <i>this</i> bacterial taxon name was published.
         * For instance if the bacterial taxon name is
         * 'Bacillus (subgen. Aerobacillus Donker 1926, 128) polymyxa' the subgenus
-        * authorship string is 'Donker 1926, 128'. 
-        * 
+        * authorship string is 'Donker 1926, 128'.
+        *
         * @return  the string containing the complete subgenus' authorship
         *                      included in <i>this</i> bacterial taxon name
         */
@@ -147,7 +159,7 @@ public class BacterialName extends NonViralName {
         * <li>are validly published as paper in IJSB after 1980 (VP).
         * </ul>
         * IJSB is the acronym for International Journal of Systematic Bacteriology.
-        * 
+        *
         * @return  the string with the source of the approbation for <i>this</i> bacterial taxon name
         */
        public String getNameApprobation(){
@@ -160,8 +172,8 @@ public class BacterialName extends NonViralName {
        public void setNameApprobation(String nameApprobation){
                this.nameApprobation = nameApprobation;
        }
-       
-       
+
+
        /**
         * Returns the {@link NomenclaturalCode nomenclatural code} that governs
         * the construction of <i>this</i> bacterial taxon name, that is the
@@ -172,11 +184,27 @@ public class BacterialName extends NonViralName {
         * @see         NonViralName#isCodeCompliant()
         * @see         TaxonNameBase#getHasProblem()
         */
-       @Transient
        @Override
        public NomenclaturalCode getNomenclaturalCode(){
                return NomenclaturalCode.ICNB;
 
        }
 
+//*********************** CLONE ********************************************************/
+
+       /**
+        * Clones <i>this</i> bacterial name. This is a shortcut that enables to create
+        * a new instance that differs only slightly from <i>this</i> bacterial name by
+        * modifying only some of the attributes.
+        *
+        * @see eu.etaxonomy.cdm.model.name.NonViralName#clone()
+        * @see java.lang.Object#clone()
+        */
+       @Override
+       public Object clone() {
+               BacterialName result = (BacterialName)super.clone();
+               //no changes to: subGenusAuthorship, nameApprobation
+               return result;
+       }
+
 }