/*
- * Copyright (C) 2016 - 2022 Free Software Foundation
+ * Copyright (C) 2016 - 2024 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import org.mxchange.jcoreutils.comparable.ComparableUtils;
+import org.mxchange.jcoreutils.number.SafeNumberUtils;
import org.mxchange.jjobs.model.skill.JobSkill;
import org.mxchange.jjobs.model.skill.Skillable;
+import org.mxchange.jjobs.model.utils.SkillUtils;
import org.mxchange.jusercore.model.user.LoginUser;
import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.utils.UserUtils;
/**
* A POJO entity for user skills
this.skillUser = skillUser;
}
+ @Override
+ public int compareTo (final SkillableUser user) {
+ // Checkparameter and return 0 if equal
+ if (null == user) {
+ // Should not happen
+ throw new NullPointerException("Parameter 'user' is null"); //NOI18N
+ } else if (Objects.equals(this, user)) {
+ // Same object
+ return 0;
+ }
+
+ // Init comparitors
+ final int comparitors[] = {
+ // First compare user
+ UserUtils.compare(this.getSkillUser(), user.getSkillUser()),
+ // Next skill
+ SkillUtils.compare(this.getJobSkill(), user.getJobSkill()),
+ // Primary key
+ SafeNumberUtils.compare(this.getUserSkillId(), user.getUserSkillId())
+ };
+
+ // Check all values
+ final int comparison = ComparableUtils.checkAll(comparitors);
+
+ // Return value
+ return comparison;
+ }
+
@Override
public boolean equals (final Object object) {
if (this == object) {