cleanup
authorAndreas Müller <a.mueller@bgbm.org>
Tue, 5 Jul 2022 20:19:57 +0000 (22:19 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Tue, 5 Jul 2022 20:19:57 +0000 (22:19 +0200)
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/PolytomousKey.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/PolytomousKeyNode.java

index 7d0a2e26a2c87b3046b243a9d2e8639fd0f69b91..933b06be7ac9cf6dbd6beadbc5f694284d0caf1d 100644 (file)
@@ -30,7 +30,8 @@ import javax.xml.bind.annotation.XmlSchemaType;
 import javax.xml.bind.annotation.XmlType;
 
 import org.apache.commons.lang3.StringUtils;
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.hibernate.annotations.Cascade;
 import org.hibernate.annotations.CascadeType;
 import org.hibernate.envers.Audited;
@@ -202,7 +203,7 @@ public class PolytomousKey
     @Override
     public Set<Taxon> getCoveredTaxa() {
         if (coveredTaxa == null) {
-            this.coveredTaxa = new HashSet<Taxon>();
+            this.coveredTaxa = new HashSet<>();
         }
         return coveredTaxa;
     }
@@ -248,7 +249,7 @@ public class PolytomousKey
     @Override
     public Set<NamedArea> getGeographicalScope() {
         if (geographicalScope == null) {
-            this.geographicalScope = new HashSet<NamedArea>();
+            this.geographicalScope = new HashSet<>();
         }
         return geographicalScope;
     }
@@ -287,7 +288,7 @@ public class PolytomousKey
     @Override
     public Set<Taxon> getTaxonomicScope() {
         if (taxonomicScope == null) {
-            this.taxonomicScope = new HashSet<Taxon>();
+            this.taxonomicScope = new HashSet<>();
         }
         return taxonomicScope;
     }
@@ -326,7 +327,7 @@ public class PolytomousKey
     @Override
     public Set<DefinedTerm> getScopeRestrictions() {
         if (scopeRestrictions == null) {
-            this.scopeRestrictions = new HashSet<DefinedTerm>();
+            this.scopeRestrictions = new HashSet<>();
         }
         return scopeRestrictions;
     }
@@ -380,19 +381,6 @@ public class PolytomousKey
 
     // ******************** toString *****************************************/
 
-    private class IntegerObject {
-        int number = 0;
-
-        int inc() {
-            return number++;
-        };
-
-        @Override
-        public String toString() {
-            return String.valueOf(number);
-        }
-    }
-
     public String print(PrintStream stream) {
         String title = this.getTitleCache() + "\n";
         String strPrint = title;
@@ -498,7 +486,7 @@ public class PolytomousKey
     }
 
 
-    // *********************** CLONE ************************************/
+// *********************** CLONE ************************************/
 
     /**
      * Clones <i>this</i> PolytomousKey. This is a shortcut that enables to
@@ -515,24 +503,24 @@ public class PolytomousKey
         try {
             result = (PolytomousKey) super.clone();
 
-            result.coveredTaxa = new HashSet<Taxon>();
+            result.coveredTaxa = new HashSet<>();
             for (Taxon taxon : this.coveredTaxa) {
                 result.addCoveredTaxon(taxon);
             }
 
-            result.geographicalScope = new HashSet<NamedArea>();
+            result.geographicalScope = new HashSet<>();
             for (NamedArea area : this.geographicalScope) {
                 result.addGeographicalScope(area);
             }
 
             result.root = this.root.clone();
 
-            result.scopeRestrictions = new HashSet<DefinedTerm>();
+            result.scopeRestrictions = new HashSet<>();
             for (DefinedTerm scope : this.scopeRestrictions) {
                 result.addScopeRestriction(scope);
             }
 
-            result.taxonomicScope = new HashSet<Taxon>();
+            result.taxonomicScope = new HashSet<>();
             for (Taxon taxon : this.taxonomicScope) {
                 result.addTaxonomicScope(taxon);
             }
@@ -545,4 +533,4 @@ public class PolytomousKey
             return null;
         }
     }
-}
+}
\ No newline at end of file
index 56422252a4ef368e472d1f4351416e8d92234701..48d595f292686fab33e6bc970f634eb39515f598 100644 (file)
@@ -303,16 +303,10 @@ public class PolytomousKeyNode extends VersionableEntity implements IMultiLangua
         //do nothing
        }
 
-       /**
-        * @return
-        */
+
        public PolytomousKey getKey() {
                return key;
        }
-
-       /**
-        * @param key
-        */
        public void setKey(PolytomousKey key) {
                this.key = key;
        }
@@ -627,7 +621,7 @@ public class PolytomousKeyNode extends VersionableEntity implements IMultiLangua
         * node. If the list does not contain this node then -1 will be returned.
         *
         * @param node
-        *            the feature node the position of which is being searched
+        *            the polytomous key node the position of which is searched
         * @see #addChild(PolytomousKeyNode, int)
         * @see #removeChild(int)
         */
@@ -640,7 +634,7 @@ public class PolytomousKeyNode extends VersionableEntity implements IMultiLangua
        }
 
        /**
-        * Returns the boolean value indicating if <i>this</i> feature node has
+        * Returns the boolean value indicating if <i>this</i> polytomous key node has
         * children (false) or not (true). A node without children is at the
         * bottommost level of a tree and is called a leaf.
         *
@@ -831,6 +825,12 @@ public class PolytomousKeyNode extends VersionableEntity implements IMultiLangua
            }
        }
 
+    public Taxon removeTaxon() {
+        Taxon result = taxon;
+        this.taxon = null;
+        return result;
+    }
+
     private boolean emptyChildNodeExists() {
         for (PolytomousKeyNode child : this.children){
             if (child.getStatement() == null && child.getQuestion() == null && child.getChildren().isEmpty()
@@ -858,9 +858,9 @@ public class PolytomousKeyNode extends VersionableEntity implements IMultiLangua
                PolytomousKeyNode result;
                try {
                        result = (PolytomousKeyNode) super.clone();
-                       result.children = new ArrayList<PolytomousKeyNode>();
+                       result.children = new ArrayList<>();
 
-                       result.modifyingText = new HashMap<Language, LanguageString>();
+                       result.modifyingText = new HashMap<>();
                        for (Entry<Language, LanguageString> entry : this.modifyingText
                                        .entrySet()) {
                                result.putModifyingText(entry.getValue());
@@ -874,10 +874,4 @@ public class PolytomousKeyNode extends VersionableEntity implements IMultiLangua
                }
        }
 
-    public Taxon removeTaxon() {
-        Taxon result = taxon;
-        this.taxon = null;
-        return result;
-    }
-
 }
\ No newline at end of file