From 942c13f4b1ceb67fc37c1df42c8c7065686a9f94 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Fri, 16 Mar 2018 00:34:52 +0100
Subject: [PATCH] Continued: - added utility class Comparables which is
 intended for compareTo() tests on   objects/entities - changed copyright to
 Free Software Foundation
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

Signed-off-by: Roland Häder <roland@mxchange.org>
---
 .../mxchange/jcoreee/utils/Comparables.java   | 69 +++++++++++++++++++
 .../mxchange/jcoreee/utils/StringUtils.java   |  6 +-
 2 files changed, 72 insertions(+), 3 deletions(-)
 create mode 100644 src/org/mxchange/jcoreee/utils/Comparables.java

diff --git a/src/org/mxchange/jcoreee/utils/Comparables.java b/src/org/mxchange/jcoreee/utils/Comparables.java
new file mode 100644
index 0000000..b5287f0
--- /dev/null
+++ b/src/org/mxchange/jcoreee/utils/Comparables.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2018 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
+ * 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.jcoreee.utils;
+
+import java.io.Serializable;
+
+/**
+ * An utilities class for comparison of objects/entities
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class Comparables implements Serializable {
+
+	/**
+	 * Serial number
+	 */
+	private static final long serialVersionUID = 19_286_457_671_390L;
+
+	/**
+	 * Checks all comparison values if they are not zero and returns proper
+	 * value. These comparators should come from an implementation of
+	 * Comparable.compareTo().
+	 * <p>
+	 * @param comparators An array of at least one comparator
+	 * <p>
+	 * @return Comparison value
+	 */
+	public static int checkAll (final int[] comparators) {
+		// Is array empty?
+		if (comparators.length == 0) {
+			// Should not happen
+			throw new IllegalArgumentException("comparators is empty."); //NOI18N
+		}
+
+		// Loop through all
+		for (int i = 0; i < comparators.length; i++) {
+			// Is it smaller or bigger?
+			if (comparators[i] < 0) {
+				return -1;
+			} else if (comparators[i] > 0) {
+				return 1;
+			}
+		}
+
+		// Assume euqality
+		return 0;
+	}
+
+	/**
+	 * Utility classes should not have instances
+	 */
+	private Comparables () {
+	}
+
+}
diff --git a/src/org/mxchange/jcoreee/utils/StringUtils.java b/src/org/mxchange/jcoreee/utils/StringUtils.java
index 7a3d6c2..e69535a 100644
--- a/src/org/mxchange/jcoreee/utils/StringUtils.java
+++ b/src/org/mxchange/jcoreee/utils/StringUtils.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Roland Häder<roland@mxchange.org>
+ * Copyright (C) 2018 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
@@ -42,7 +42,7 @@ public class StringUtils implements Serializable {
 	 *         2 means str0 bigger str2
 	 */
 	@SuppressWarnings ("null")
-	public static int comareTo (final String str0, final String str1) {
+	public static int compareTo (final String str0, final String str1) {
 		// Check both strings for null and empty
 		boolean isStr0Empty = (str0 == null || str0.isEmpty());
 		boolean isStr1Empty = (str1 == null || str1.isEmpty());
@@ -72,7 +72,7 @@ public class StringUtils implements Serializable {
 	 *         2 means str0 bigger str2
 	 */
 	@SuppressWarnings ("null")
-	public static int comareToIgnoreCase (final String str0, final String str1) {
+	public static int compareToIgnoreCase (final String str0, final String str1) {
 		// Check both strings for null and empty
 		boolean isStr0Empty = (str0 == null || str0.isEmpty());
 		boolean isStr1Empty = (str1 == null || str1.isEmpty());
-- 
2.39.5