2 * Copyright (C) 2022 Free Software Foundation
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.jcoreutils.comparable;
19 import java.io.Serializable;
22 * An utilities class for comparison of objects/entities
24 * @author Roland Häder<roland@mxchange.org>
26 public class ComparableUtils implements Serializable {
31 private static final long serialVersionUID = 19_286_457_671_390L;
34 * Checks all comparison values if they are not zero and returns proper
35 * value. These comparators should come from an implementation of
36 * Comparable.compareTo().
38 * @param comparators An array of at least one comparator
40 * @return Comparison value
42 public static int checkAll (final int[] comparators) {
44 if (comparators.length == 0) {
46 throw new IllegalArgumentException("comparators is empty."); //NOI18N
50 for (int i = 0; i < comparators.length; i++) {
51 // Is it smaller or bigger?
52 if (comparators[i] < 0) {
54 } else if (comparators[i] > 0) {
64 * Utility classes should not have instances
66 private ComparableUtils () {