]> git.mxchange.org Git - jjobs-core.git/blobdiff - src/org/mxchange/jjobs/model/utils/SkillUtils.java
Continued:
[jjobs-core.git] / src / org / mxchange / jjobs / model / utils / SkillUtils.java
diff --git a/src/org/mxchange/jjobs/model/utils/SkillUtils.java b/src/org/mxchange/jjobs/model/utils/SkillUtils.java
new file mode 100644 (file)
index 0000000..0549b65
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2023 Roland Häder<roland@mxchange.org>
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jjobs.model.utils;
+
+import java.util.Objects;
+import org.mxchange.jjobs.model.skill.Skillable;
+
+/**
+ * Utilities class for skills to learn and practice
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class SkillUtils {
+
+       /**
+        * Compares two skills with each other
+        * <p>
+        * @param skill1 Skill instance 1
+        * @param skill2 Skill instance 2
+        * <p>
+        * @return Comparison value
+        */
+       public static int compare (final Skillable skill1, final Skillable skill2) {
+               // Check equality, then at least first must be given
+               if (Objects.equals(skill1, skill2)) {
+                       // Both are same
+                       return 0;
+               } else if (null == skill1) {
+                       // First is null
+                       return -1;
+               } else if (null == skill2) {
+                       // Second is null
+                       return 1;
+               }
+
+               // Invoke compare() method
+               return skill1.compareTo(skill2);
+       }
+
+       /**
+        * Utilities classes don't have constructors
+        */
+       private SkillUtils () {
+       }
+}