src/share/classes/java/lang/Short.java
Print this page
rev 6190 : [mq]: reducers
*** 529,536 ****
--- 529,578 ----
*/
public static long toUnsignedLong(short x) {
return ((long) x) & 0xffffL;
}
+ /**
+ * Adds two {@code short} values together as per the + operator.
+ * Suitable for conversion as a method reference to functional interfaces such
+ * as {@code BinaryOperator<Short>}.
+ *
+ * @param a an argument.
+ * @param b another argument.
+ * @return the sum of {@code a} and {@code b}.
+ * @since 1.8
+ */
+ public static short sum(short a, short b) {
+ return (short) (a + b);
+ }
+
+ /**
+ * Returns the greater of two {@code short} values.
+ * Suitable for conversion as a method reference to functional interfaces such
+ * as {@code BinaryOperator<Short>}.
+ *
+ * @param a an argument.
+ * @param b another argument.
+ * @return the larger of {@code a} and {@code b}.
+ * @since 1.8
+ */
+ public static short max(short a, short b) {
+ return (a >= b) ? a : b;
+ }
+
+ /**
+ * Returns the lesser of two {@code short} values.
+ * Suitable for conversion as a method reference to functional interfaces such
+ * as {@code BinaryOperator<Short>}.
+ *
+ * @param a an argument.
+ * @param b another argument.
+ * @return the lesser of {@code a} and {@code b}.
+ * @since 1.8
+ */
+ public static short min(short a, short b) {
+ return (a <= b) ? a : b;
+ }
+
/** use serialVersionUID from JDK 1.1. for interoperability */
private static final long serialVersionUID = 7515723908773894738L;
}