]> git.mxchange.org Git - jcore-utils.git/blobdiff - src/org/mxchange/jcoreutils/bool/BooleanUtils.java
Continued:
[jcore-utils.git] / src / org / mxchange / jcoreutils / bool / BooleanUtils.java
diff --git a/src/org/mxchange/jcoreutils/bool/BooleanUtils.java b/src/org/mxchange/jcoreutils/bool/BooleanUtils.java
new file mode 100644 (file)
index 0000000..c1e041d
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2022 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.jcoreutils.bool;
+
+import java.util.Objects;
+
+/**
+ * Utilities class for Boolean instances (not primitive boolean)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class BooleanUtils {
+
+       /**
+        * Compares two Boolean instances with each other
+        * <p>
+        * @param boolean1 Boolean instance 1
+        * @param boolean2 Boolean instance 2
+        * <p>
+        * @return Comparison value
+        */
+       public static int compare (final Boolean boolean1, final Boolean boolean2) {
+               // Check parameter
+               if (Objects.equals(boolean1, boolean2)) {
+                       // Same object
+                       return 0;
+               } else if (null == boolean1) {
+                       // Left side is null
+                       return -1;
+               } else if (null == boolean2) {
+                       // Right side is null
+                       return 1;
+               }
+
+               // Compare instances
+               return boolean1.compareTo(boolean2);
+       }
+
+       /**
+        * No instance from utility classes
+        */
+       private BooleanUtils () {
+       }
+
+}