Signed-off-by: Pekka Enberg <penb...@kernel.org>
---
 java/lang/Boolean.java   |   15 +++++++++++++++
 java/lang/Byte.java      |   17 +++++++++++++++++
 java/lang/Character.java |   17 +++++++++++++++++
 java/lang/Integer.java   |   17 +++++++++++++++++
 java/lang/Long.java      |   17 +++++++++++++++++
 java/lang/Short.java     |   17 +++++++++++++++++
 6 files changed, 100 insertions(+), 0 deletions(-)

diff --git a/java/lang/Boolean.java b/java/lang/Boolean.java
index f2eaf41..0e4afa8 100644
--- a/java/lang/Boolean.java
+++ b/java/lang/Boolean.java
@@ -237,6 +237,21 @@ public final class Boolean implements Serializable, 
Comparable<Boolean>
   }
 
   /**
+   * Compares two unboxed boolean values.
+   *
+   * @param x First value to compare.
+   * @param y Second value to compare.
+   * @return 0 if both Booleans represent the same value, a positive number
+   * if this Boolean represents true and the other false, and a negative
+   * number otherwise.
+   * @since 1.7
+   */
+  public static int compare(boolean x, boolean y)
+  {
+    return Boolean.valueOf(x).compareTo(Boolean.valueOf(y));
+  }
+
+  /**
    * If the String argument is "true", ignoring case, return true.
    * Otherwise, return false.
    *
diff --git a/java/lang/Byte.java b/java/lang/Byte.java
index a1536e1..01e0e03 100644
--- a/java/lang/Byte.java
+++ b/java/lang/Byte.java
@@ -370,4 +370,21 @@ public final class Byte extends Number implements 
Comparable<Byte>
     return value - b.value;
   }
 
+  /**
+   * Compares two unboxed byte values.
+   * The result is positive if the first is greater, negative if the second
+   * is greater, and 0 if the two are equal.
+   *
+   * @param x First value to compare.
+   * @param y Second value to compare.
+   *
+   * @return positive int if the first value is greater, negative if the second
+   * is greater, and 0 if the two are equal.
+   * @since 1.7
+   */
+  public static int compare(byte x, byte y)
+  {
+    return Byte.valueOf(x).compareTo(Byte.valueOf(y));
+  }
+
 }
diff --git a/java/lang/Character.java b/java/lang/Character.java
index 05e641c..f87cde6 100644
--- a/java/lang/Character.java
+++ b/java/lang/Character.java
@@ -4200,6 +4200,23 @@ public final class Character implements Serializable, 
Comparable<Character>
   }
 
   /**
+   * Compares two unboxed char values.
+   * The result is positive if the first is greater, negative if the second
+   * is greater, and 0 if the two are equal.
+   *
+   * @param x First value to compare.
+   * @param y Second value to compare.
+   *
+   * @return positive int if the first value is greater, negative if the second
+   * is greater, and 0 if the two are equal.
+   * @since 1.7
+   */
+  public static int compare(char x, char y)
+  {
+    return Character.valueOf(x).compareTo(Character.valueOf(y));
+  }
+
+  /**
    * Returns an <code>Character</code> object wrapping the value.
    * In contrast to the <code>Character</code> constructor, this method
    * will cache some values.  It is used by boxing conversion.
diff --git a/java/lang/Integer.java b/java/lang/Integer.java
index f379795..25eb5d5 100644
--- a/java/lang/Integer.java
+++ b/java/lang/Integer.java
@@ -586,6 +586,23 @@ public final class Integer extends Number implements 
Comparable<Integer>
   }
 
   /**
+   * Compares two unboxed int values.
+   * The result is positive if the first is greater, negative if the second
+   * is greater, and 0 if the two are equal.
+   *
+   * @param x First value to compare.
+   * @param y Second value to compare.
+   *
+   * @return positive int if the first value is greater, negative if the second
+   * is greater, and 0 if the two are equal.
+   * @since 1.7
+   */
+  public static int compare(int x, int y)
+  {
+    return Integer.valueOf(x).compareTo(Integer.valueOf(y));
+  }
+
+  /**
    * Return the number of bits set in x.
    * @param x value to examine
    * @since 1.5
diff --git a/java/lang/Long.java b/java/lang/Long.java
index e7579d8..6f31dfa 100644
--- a/java/lang/Long.java
+++ b/java/lang/Long.java
@@ -585,6 +585,23 @@ public final class Long extends Number implements 
Comparable<Long>
   }
 
   /**
+   * Compares two unboxed long values.
+   * The result is positive if the first is greater, negative if the second
+   * is greater, and 0 if the two are equal.
+   *
+   * @param x First value to compare.
+   * @param y Second value to compare.
+   *
+   * @return positive int if the first value is greater, negative if the second
+   * is greater, and 0 if the two are equal.
+   * @since 1.7
+   */
+  public static int compare(long x, long y)
+  {
+    return Long.valueOf(x).compareTo(Long.valueOf(y));
+  }
+
+  /**
    * Return the number of bits set in x.
    * @param x value to examine
    * @since 1.5
diff --git a/java/lang/Short.java b/java/lang/Short.java
index ec87f93..fae9fe7 100644
--- a/java/lang/Short.java
+++ b/java/lang/Short.java
@@ -373,6 +373,23 @@ public final class Short extends Number implements 
Comparable<Short>
   }
 
   /**
+   * Compares two unboxed short values.
+   * The result is positive if the first is greater, negative if the second
+   * is greater, and 0 if the two are equal.
+   *
+   * @param x First value to compare.
+   * @param y Second value to compare.
+   *
+   * @return positive int if the first value is greater, negative if the second
+   * is greater, and 0 if the two are equal.
+   * @since 1.7
+   */
+  public static int compare(short x, short y)
+  {
+    return Short.valueOf(x).compareTo(Short.valueOf(y));
+  }
+
+  /**
    * Reverse the bytes in val.
    * @since 1.5
    */
-- 
1.7.6.5


Reply via email to