src/share/classes/java/lang/Boolean.java

Print this page
rev 6190 : [mq]: reducers


 273         return compare(this.value, b.value);
 274     }
 275 
 276     /**
 277      * Compares two {@code boolean} values.
 278      * The value returned is identical to what would be returned by:
 279      * <pre>
 280      *    Boolean.valueOf(x).compareTo(Boolean.valueOf(y))
 281      * </pre>
 282      *
 283      * @param  x the first {@code boolean} to compare
 284      * @param  y the second {@code boolean} to compare
 285      * @return the value {@code 0} if {@code x == y};
 286      *         a value less than {@code 0} if {@code !x && y}; and
 287      *         a value greater than {@code 0} if {@code x && !y}
 288      * @since 1.7
 289      */
 290     public static int compare(boolean x, boolean y) {
 291         return (x == y) ? 0 : (x ? 1 : -1);
 292     }













































 293 }


 273         return compare(this.value, b.value);
 274     }
 275 
 276     /**
 277      * Compares two {@code boolean} values.
 278      * The value returned is identical to what would be returned by:
 279      * <pre>
 280      *    Boolean.valueOf(x).compareTo(Boolean.valueOf(y))
 281      * </pre>
 282      *
 283      * @param  x the first {@code boolean} to compare
 284      * @param  y the second {@code boolean} to compare
 285      * @return the value {@code 0} if {@code x == y};
 286      *         a value less than {@code 0} if {@code !x && y}; and
 287      *         a value greater than {@code 0} if {@code x && !y}
 288      * @since 1.7
 289      */
 290     public static int compare(boolean x, boolean y) {
 291         return (x == y) ? 0 : (x ? 1 : -1);
 292     }
 293 
 294     /**
 295      * Returns the result of applying the logical AND operator to the
 296      * specified {@code boolean} parameters.
 297      * Suitable for conversion as a method reference to functional interfaces such
 298      * as {@code BinaryOperator&lt;Boolean&gt;}.
 299      *
 300      * @param   a   a boolean argument.
 301      * @param   b   another boolean argument.
 302      * @return  the logical AND of {@code a} and {@code b}.
 303      * @since 1.8
 304      */
 305     public static boolean logicalAnd(boolean a, boolean b) {
 306         return a && b;
 307     }
 308 
 309     /**
 310      * Returns the result of applying the logical OR operator to the
 311      * specified {@code boolean} parameters.
 312      * Suitable for conversion as a method reference to functional interfaces such
 313      * as {@code BinaryOperator&lt;Boolean&gt;}.
 314      *
 315      * @param   a   a boolean argument.
 316      * @param   b   another boolean argument.
 317      * @return  the logical OR of {@code a} and {@code b}.
 318      * @since 1.8
 319      */
 320     public static boolean logicalOr(boolean a, boolean b) {
 321         return a || b;
 322     }
 323 
 324     /**
 325      * Returns the result of applying the logical XOR operator to the
 326      * specified {@code boolean} parameters.
 327      * Suitable for conversion as a method reference to functional interfaces such
 328      * as {@code BinaryOperator&lt;Boolean&gt;}.
 329      *
 330      * @param   a   a boolean argument.
 331      * @param   b   another boolean argument.
 332      * @return  the logical XOR of {@code a} and {@code b}.
 333      * @since 1.8
 334      */
 335     public static boolean logicalXor(boolean a, boolean b) {
 336         return a ^ b;
 337     }
 338 }