]> git.mxchange.org Git - jjobs-core.git/blobdiff - src/org/mxchange/jjobs/model/utils/SkillUtils.java
Continued:
[jjobs-core.git] / src / org / mxchange / jjobs / model / utils / SkillUtils.java
index 2a57e2ec270e0ae603fa43ee65e73cbb374d0ff5..4b42105e476d3c48d3825220b92c8baa638f7c58 100644 (file)
@@ -17,6 +17,7 @@
 package org.mxchange.jjobs.model.utils;
 
 import java.util.Objects;
+import org.apache.commons.lang3.StringUtils;
 import org.mxchange.jjobs.model.skill.Skillable;
 
 /**
@@ -78,6 +79,53 @@ public class SkillUtils {
                targetSkillable.setSkillStatus(sourceSkillable.getSkillStatus());
        }
 
+       /**
+        * Checks if both instances are the same
+        * <p>
+        * @param skillable1 First instance of a Skillable class
+        * @param skillable2 Second instance of a Skillable class
+        * <p>
+        * @return Whether they are the same
+        */
+       public static boolean isSameSkill (final Skillable skillable1, final Skillable skillable2) {
+               // Validate parameter
+               if (null == skillable1) {
+                       // Throw NPE
+                       throw new NullPointerException("Parameter 'skillable1' is null"); // NOI18N
+               } else if (null == skillable2) {
+                       // Throw it again
+                       throw new NullPointerException("Parameter 'skillable2' is null"); // NOI18N
+               } else if (Objects.equals(skillable1, skillable2)) {
+                       // Is the same
+                       return true;
+               } else if (skillable1.getSkillName() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("skillable1.skillName is null"); // NOI18N
+               } else if (skillable1.getSkillName().isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("skillable1.skillName is empty"); // NOI18N
+               } else if (skillable2.getSkillName() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("skillable2.skillName is null"); // NOI18N
+               } else if (skillable2.getSkillName() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("skillable2.skillName is null"); // NOI18N
+               } else if (skillable2.getSkillName().isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("skillable2.skillName is empty"); // NOI18N
+               } else if (skillable1.getSkillStatus() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("skillable1.skillStatus is null"); // NOI18N
+               } else if (skillable2.getSkillStatus() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("skillable2.skillStatus is null"); // NOI18N
+               }
+
+               // Now that all at least required fields are there, let's check them all
+               return ((StringUtils.equals(skillable1.getSkillName(), skillable2.getSkillName())) &&
+                               (skillable1.getSkillStatus().equals(skillable2.getSkillStatus())));
+       }
+
        /**
         * Utilities classes don't have constructors
         */