2 * Copyright (C) 2023 Roland Häder<roland@mxchange.org>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jjobs.model.utils;
19 import java.util.Objects;
20 import org.mxchange.jjobs.model.skill.Skillable;
23 * Utilities class for skills to learn and practice
25 * @author Roland Häder<roland@mxchange.org>
27 public class SkillUtils {
30 * Compares two skills with each other
32 * @param skill1 Skill instance 1
33 * @param skill2 Skill instance 2
35 * @return Comparison value
37 public static int compare (final Skillable skill1, final Skillable skill2) {
38 // Check equality, then at least first must be given
39 if (Objects.equals(skill1, skill2)) {
42 } else if (null == skill1) {
45 } else if (null == skill2) {
50 // Invoke compare() method
51 return skill1.compareTo(skill2);
55 * Copies all fields exception created/updated timestamps from source
56 * Skillable instance to target instance all fields.
58 * @param sourceSkillable Source instance of a Skillable class
59 * @param targetSkillable Target instance of a Skillable class
61 public static void copySkillData (final Skillable sourceSkillable, final Skillable targetSkillable) {
62 // Check that both parameters are not null
63 if (null == sourceSkillable) {
65 throw new NullPointerException("sourceSkillable is null"); //NOI18N
66 } else if (null == targetSkillable) {
68 throw new NullPointerException("targetSkillable is null"); //NOI18N
69 } else if (Objects.equals(sourceSkillable, targetSkillable)) {
71 throw new IllegalArgumentException("sourceSkillable and targetSkillable are the same"); //NOI18N
75 targetSkillable.setSkillId(sourceSkillable.getSkillId());
76 targetSkillable.setSkillLastLocked(sourceSkillable.getSkillLastLocked());
77 targetSkillable.setSkillName(sourceSkillable.getSkillName());
78 targetSkillable.setSkillStatus(sourceSkillable.getSkillStatus());
82 * Utilities classes don't have constructors
84 private SkillUtils () {