/**
* Link to skill entity
*/
- @JoinColumn(name = "skill_job_skill_id", nullable = false,updatable = false, referencedColumnName = "skill_id")
+ @JoinColumn (name = "skill_job_skill_id", nullable = false, updatable = false, referencedColumnName = "skill_id")
@OneToOne (cascade = CascadeType.REFRESH, targetEntity = JobSkill.class)
private Skillable jobSkill;
/**
- * User added this skill (optional as administrators can add skills,
- * too)
+ * User added this skill (optional as administrators can add skills, too)
*/
@JoinColumn (name = "skill_job_user_id", referencedColumnName = "user_id")
@OneToOne (cascade = CascadeType.REFRESH, targetEntity = LoginUser.class)
@Column (name = "skill_job_importance", nullable = false)
private Short skillImportance;
+ /**
+ * Default constructor, required for the JPA.
+ */
+ public JobPositionSkill () {
+ // Nothing to do here
+ }
+
+ /**
+ * Constructor with all required entity properties
+ * <p>
+ * @param jobPosition An instance of a HireableJobPosition class
+ * @param jobSkill An instance of a Skillable class
+ * @param skillImportance Importance level
+ */
+ public JobPositionSkill (final HireableJobPosition jobPosition, final Skillable jobSkill, final Short skillImportance) {
+ // Invoke default constructor
+ this();
+
+ // Set fields
+ this.jobPosition = jobPosition;
+ this.jobSkill = jobSkill;
+ this.skillImportance = skillImportance;
+ }
+
@Override
public boolean equals (final Object object) {
if (this == object) {
return false;
}
- final SkillableJobPosition other = (SkillableJobPosition) object;
+ final SkillableJobPosition jobPosition = (SkillableJobPosition) object;
- if (!Objects.equals(this.getJobPositionSkillId(), other.getJobPositionSkillId())) {
+ if (!Objects.equals(this.getSkillImportance(), jobPosition.getSkillImportance())) {
return false;
- } else if (!Objects.equals(this.getSkillImportance(), other.getSkillImportance())) {
+ } else if (!Objects.equals(this.getJobPosition(), jobPosition.getJobPosition())) {
+ return false;
+ } else if (!Objects.equals(this.getJobSkill(), jobPosition.getJobSkill())) {
+ return false;
+ } else if (!Objects.equals(this.getJobPositionSkillId(), jobPosition.getJobPositionSkillId())) {
return false;
}
public int hashCode () {
int hash = 5;
- hash = 41 * hash + Objects.hashCode(this.getJobPositionSkillId());
+ hash = 41 * hash + Objects.hashCode(this.getJobPosition());
+ hash = 41 * hash + Objects.hashCode(this.getJobSkill());
hash = 41 * hash + Objects.hashCode(this.getSkillImportance());
+ hash = 41 * hash + Objects.hashCode(this.getJobPositionSkillId());
return hash;
}
@Temporal (TemporalType.TIMESTAMP)
private Date skillUpdated;
+ /**
+ * Default constructor, required for the JPA.
+ */
+ public JobSkill () {
+ // Nothing to do here
+ }
+
+ /**
+ * Constructor with required fields
+ * <p>
+ * @param skillName Name of skill
+ * @param skillStatus Status
+ */
+ public JobSkill (final String skillName, final SkillStatus skillStatus) {
+ // Call default constructor (always and regardless)
+ this();
+
+ // Validate parameter
+ if (null == skillName) {
+ // Throw NPE
+ throw new NullPointerException("skillName is null"); //NOI18N
+ } else if (skillName.isEmpty()) {
+ // Throw IAE
+ throw new IllegalArgumentException("skillName is empty"); //NOI18N
+ } else if (null == skillStatus) {
+ // Throw NPE
+ throw new NullPointerException("skillStatus is null"); //NOI18N
+ }
+
+ // Set fields
+ this.skillName = skillName;
+ this.skillStatus = skillStatus;
+ }
+
@Override
public boolean equals (final Object object) {
if (this == object) {
return false;
}
- final Skillable other = (Skillable) object;
+ final Skillable skill = (Skillable) object;
- if (!Objects.equals(this.getSkillName(), other.getSkillName())) {
+ if (!Objects.equals(this.getSkillStatus(), skill.getSkillStatus())) {
+ return false;
+ } else if (!Objects.equals(this.getSkillName(), skill.getSkillName())) {
return false;
- } else if (!Objects.equals(this.getSkillId(), other.getSkillId())) {
+ } else if (!Objects.equals(this.getSkillId(), skill.getSkillId())) {
return false;
}
hash = 97 * hash + Objects.hashCode(this.getSkillId());
hash = 97 * hash + Objects.hashCode(this.getSkillName());
+ hash = 97 * hash + Objects.hashCode(this.getSkillStatus());
return hash;
}
import org.mxchange.jjobs.model.skill.JobSkill;
import org.mxchange.jjobs.model.skill.Skillable;
import java.util.Date;
+import java.util.Objects;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@Temporal (TemporalType.TIMESTAMP)
private Date userSkillUpdated;
+ /**
+ * Default constructor, required for the EJB
+ */
+ public UserSkill () {
+ // Empty by default
+ }
+
+ /**
+ * Constructor with all required entity properties
+ * <p>
+ * @param jobSkill An instance of a Skillable class
+ * @param skillUser An instance of a User class
+ */
+ public UserSkill (final Skillable jobSkill, final User skillUser) {
+ // Invoke default constructor
+ this();
+
+ // Validate parameter
+ if (null == jobSkill) {
+ // Throw NPE
+ throw new NullPointerException("jobSkill is null"); //NOI18N
+ } else if (null == skillUser) {
+ // Throw NPE
+ throw new NullPointerException("skillUser is null"); //NOI18N
+ }
+
+ // Set fields
+ this.jobSkill = jobSkill;
+ this.skillUser = skillUser;
+ }
+
+ @Override
+ public boolean equals (final Object object) {
+ if (this == object) {
+ return true;
+ } else if (object == null) {
+ return false;
+ } else if (getClass() != object.getClass()) {
+ return false;
+ }
+
+ final SkillableUser skillableUser = (SkillableUser) object;
+
+ if (!Objects.equals(this.getJobSkill(), skillableUser.getJobSkill())) {
+ return false;
+ } else if (!Objects.equals(this.getSkillUser(), skillableUser.getSkillUser())) {
+ return false;
+ } else if (!Objects.equals(this.getUserSkillId(), skillableUser.getUserSkillId())) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode () {
+ int hash = 7;
+
+ hash = 17 * hash + Objects.hashCode(this.getJobSkill());
+ hash = 17 * hash + Objects.hashCode(this.getSkillUser());
+ hash = 17 * hash + Objects.hashCode(this.getUserSkillId());
+
+ return hash;
+ }
+
@Override
public Skillable getJobSkill () {
return this.jobSkill;