*/
package org.mxchange.jjobs.exceptions;
+import java.text.MessageFormat;
+import org.mxchange.jjobs.model.skill.Skillable;
+
/**
* An exception being thrown when a skill instance has already been found
* <p>
*/
private static final long serialVersionUID = 42_895_928_956_700_002L;
+ /**
+ * Constructor with a Skillable class
+ * <p>
+ * @param skill An instance of a Skillable class
+ */
+ public SkillAlreadyAddedException (final Skillable skill) {
+ // Construct message and invoke super
+ super(MessageFormat.format("Skill with id={0},name={1} already added", skill.getSkillId(), skill.getSkillName()));
+ }
+
}
package org.mxchange.jjobs.model.exceptions;
import java.text.MessageFormat;
+import org.mxchange.jjobs.model.skill.Skillable;
/**
* An exception thrown when a Skillable instance wasn't found
super(MessageFormat.format("Skill id {0} not found.", skillId)); //NOI18N
}
+ /**
+ * Constructor with Skillable instance
+ * <p>
+ * @param skillable An instance of a Skillable class
+ */
+ public SkillNotFoundException (final Skillable skillable) {
+ // Construct message and invoke super
+ super(MessageFormat.format("Skill with name={0} not found.", skillable.getSkillName()));
+ }
+
}
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
*/