src/share/classes/java/lang/Byte.java
Print this page
rev 6190 : [mq]: reducers
@@ -513,8 +513,50 @@
*
* @since 1.8
*/
public static final int BYTES = SIZE / Byte.SIZE;
+ /**
+ * Adds two {@code byte}s together as per the + operator.
+ * Suitable for conversion as a method reference to functional interfaces such
+ * as {@code BinaryOperator<Byte>}.
+ *
+ * @param a an argument.
+ * @param b another argument.
+ * @return the sum of {@code a} and {@code b}.
+ * @since 1.8
+ */
+ public static byte sum(byte a, byte b) {
+ return (byte) (a + b);
+ }
+
+ /**
+ * Returns the greater of two {@code byte} values.
+ * Suitable for conversion as a method reference to functional interfaces such
+ * as {@code BinaryOperator<Byte>}.
+ *
+ * @param a an argument.
+ * @param b another argument.
+ * @return the larger of {@code a} and {@code b}.
+ * @since 1.8
+ */
+ public static byte max(byte a, byte b) {
+ return (a >= b) ? a : b;
+ }
+
+ /**
+ * Returns the lesser of two {@code byte} values.
+ * Suitable for conversion as a method reference to functional interfaces such
+ * as {@code BinaryOperator<Byte>}.
+ *
+ * @param a an argument.
+ * @param b another argument.
+ * @return the lesser of {@code a} and {@code b}.
+ * @since 1.8
+ */
+ public static byte min(byte a, byte b) {
+ return (a <= b) ? a : b;
+ }
+
/** use serialVersionUID from JDK 1.1. for interoperability */
private static final long serialVersionUID = -7183698231559129828L;
}