Beispiel #1
0
 /**
  * Returns a composed {@link BiShortPredicate} that first applies the {@code before} functions to
  * its input, and then applies this predicate to the result. If evaluation of either operation
  * throws an exception, it is relayed to the caller of the composed operation. This method is just
  * convenience, to provide the ability to execute an operation which accepts {@code short} input,
  * before this primitive predicate is executed.
  *
  * @param before1 The first function to apply before this predicate is applied
  * @param before2 The second function to apply before this predicate is applied
  * @return A composed {@code BiShortPredicate} that first applies the {@code before} functions to
  *     its input, and then applies this predicate to the result.
  * @throws NullPointerException If given argument is {@code null}
  * @implSpec The input argument of this method is a able to handle primitive values. In this case
  *     this is {@code short}.
  */
 @Nonnull
 default BiShortPredicate composeFromShort(
     @Nonnull final ShortFunction<? extends T> before1,
     @Nonnull final ShortToCharFunction before2) {
   Objects.requireNonNull(before1);
   Objects.requireNonNull(before2);
   return (value1, value2) -> test(before1.apply(value1), before2.applyAsChar(value2));
 }
 /**
  * Returns a composed {@link BiShortToFloatFunction} that first applies the {@code before}
  * functions to its input, and then applies this function to the result. If evaluation of either
  * operation throws an exception, it is relayed to the caller of the composed operation. This
  * method is just convenience, to provide the ability to execute an operation which accepts {@code
  * short} input, before this primitive function is executed.
  *
  * @param before1 The first function to apply before this function is applied
  * @param before2 The second function to apply before this function is applied
  * @return A composed {@code BiShortToFloatFunction} that first applies the {@code before}
  *     functions to its input, and then applies this function to the result.
  * @throws NullPointerException If given argument is {@code null}
  * @implSpec The input argument of this method is a able to handle primitive values. In this case
  *     this is {@code short}.
  */
 @Nonnull
 default BiShortToFloatFunction composeFromShort(
     @Nonnull final ShortFunction<? extends T> before1,
     @Nonnull final ShortToDoubleFunction before2) {
   Objects.requireNonNull(before1);
   Objects.requireNonNull(before2);
   return (value1, value2) -> applyAsFloat(before1.apply(value1), before2.applyAsDouble(value2));
 }
Beispiel #3
0
 /**
  * Returns a composed {@link TriShortConsumer} that first applies the {@code before} functions to
  * its input, and then applies this consumer to the result. If evaluation of either operation
  * throws an exception, it is relayed to the caller of the composed operation. This method is just
  * convenience, to provide the ability to execute an operation which accepts {@code short} input,
  * before this primitive consumer is executed.
  *
  * @param before1 The first function to apply before this consumer is applied
  * @param before2 The second function to apply before this consumer is applied
  * @param before3 The third function to apply before this consumer is applied
  * @return A composed {@code TriShortConsumer} that first applies the {@code before} functions to
  *     its input, and then applies this consumer to the result.
  * @throws NullPointerException If given argument is {@code null}
  * @implSpec The input argument of this method is a able to handle primitive values. In this case
  *     this is {@code short}.
  */
 @Nonnull
 default TriShortConsumer composeFromShort(
     @Nonnull final ShortFunction<? extends T> before1,
     @Nonnull final ShortToIntFunction before2,
     @Nonnull final ShortToIntFunction before3) {
   Objects.requireNonNull(before1);
   Objects.requireNonNull(before2);
   Objects.requireNonNull(before3);
   return (value1, value2, value3) ->
       accept(before1.apply(value1), before2.applyAsInt(value2), before3.applyAsInt(value3));
 }
 /**
  * Returns a composed {@link TriShortToCharFunction} that first applies the {@code before}
  * functions to its input, and then applies this function to the result. If evaluation of either
  * operation throws an exception, it is relayed to the caller of the composed operation. This
  * method is just convenience, to provide the ability to execute an operation which accepts {@code
  * short} input, before this primitive function is executed.
  *
  * @param before1 The first function to apply before this function is applied
  * @param before2 The second function to apply before this function is applied
  * @param before3 The third function to apply before this function is applied
  * @return A composed {@code TriShortToCharFunction} that first applies the {@code before}
  *     functions to its input, and then applies this function to the result.
  * @throws NullPointerException If given argument is {@code null}
  * @implSpec The input argument of this method is a able to handle primitive values. In this case
  *     this is {@code short}.
  */
 @Nonnull
 default TriShortToCharFunction composeFromShort(
     @Nonnull final ShortFunction<? extends T> before1,
     @Nonnull final ShortToByteFunction before2,
     @Nonnull final ShortToByteFunction before3) {
   Objects.requireNonNull(before1);
   Objects.requireNonNull(before2);
   Objects.requireNonNull(before3);
   return (value1, value2, value3) ->
       applyAsChar(
           before1.apply(value1), before2.applyAsByte(value2), before3.applyAsByte(value3));
 }
Beispiel #5
0
 /**
  * Calls the given {@link ShortFunction} with the given argument and returns its result.
  *
  * @param <R> The type of return value from the function
  * @param function The function to be called
  * @param value The argument to the function
  * @return The result from the given {@code ShortFunction}.
  * @throws NullPointerException If given argument is {@code null}
  */
 static <R> R call(@Nonnull final ShortFunction<? extends R> function, short value) {
   Objects.requireNonNull(function);
   return function.apply(value);
 }
Beispiel #6
0
 /**
  * Lifts a partial {@link ShortFunction} into a total {@link ShortFunction} that returns an {@link
  * Optional} result.
  *
  * @param <R> The type of return value from the function
  * @param partial A function that is only defined for some values in its domain
  * @return A partial {@code ShortFunction} lifted into a total {@code ShortFunction} that returns
  *     an {@code Optional} result.
  * @throws NullPointerException If given argument is {@code null}
  */
 @Nonnull
 static <R> ShortFunction<Optional<R>> lift(@Nonnull final ShortFunction<? extends R> partial) {
   Objects.requireNonNull(partial);
   return (value) -> Optional.ofNullable(partial.apply(value));
 }
 /**
  * Returns a composed {@link ShortFunction} that first applies this operator to its input, and
  * then applies the {@code after} function to the result. If evaluation of either operation throws
  * an exception, it is relayed to the caller of the composed operation.
  *
  * @param <S> The type of return value from the {@code after} function, and of the composed
  *     function
  * @param after The function to apply after this operator is applied
  * @return A composed {@code ShortFunction} that first applies this operator to its input, and
  *     then applies the {@code after} function to the result.
  * @throws NullPointerException If given argument is {@code null}
  * @implSpec The input argument of this method is able to return every type.
  */
 @Nonnull
 default <S> ShortFunction<S> andThen(@Nonnull final ShortFunction<? extends S> after) {
   Objects.requireNonNull(after);
   return (value) -> after.apply(applyAsShort(value));
 }