package org.mxchange.jjobs.model.utils;
import java.util.Objects;
+import org.apache.commons.lang3.StringUtils;
import org.mxchange.jjobs.model.skill.Skillable;
/**
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
*/