Interface LongUnaryOperator

All Superinterfaces:
Function<Long,​Long>, Function<Long,​Long>, LongFunction<Long>, LongFunction<Long>, LongUnaryOperator, ToLongFunction<Long>, ToLongFunction<Long>, UnaryOperator<Long>, UnaryOperator<Long>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface
public interface LongUnaryOperator
extends LongFunction<Long>, UnaryOperator<Long>, ToLongFunction<Long>, LongUnaryOperator
Represents an operation on a single long-valued operand that produces a long-valued result. This is the primitive type specialization of UnaryOperator for long.

This is a functional interface whose functional method is applyAsLong(long).

Since:
1.8
See Also:
UnaryOperator
  • Field Details

  • Method Details

    • applyAsLong

      long applyAsLong​(long operand)
      Applies this operator to the given operand.
      Specified by:
      applyAsLong in interface LongUnaryOperator
      Parameters:
      operand - the operand
      Returns:
      the operator result
    • applyAsLong

      default long applyAsLong​(Long value)
      Applies this function to the given argument.
      Specified by:
      applyAsLong in interface ToLongFunction<Long>
      Specified by:
      applyAsLong in interface ToLongFunction<Long>
      Parameters:
      value - the function argument
      Returns:
      the function result
    • apply

      default Long apply​(long value)
      Applies this function to the given argument.
      Specified by:
      apply in interface LongFunction<Long>
      Specified by:
      apply in interface LongFunction<Long>
      Parameters:
      value - the function argument
      Returns:
      the function result
    • apply

      default Long apply​(Long value)
      Applies this function to the given argument.
      Specified by:
      apply in interface Function<Long,​Long>
      Specified by:
      apply in interface Function<Long,​Long>
      Specified by:
      apply in interface LongFunction<Long>
      Specified by:
      apply in interface ToLongFunction<Long>
      Parameters:
      value - the function argument
      Returns:
      the function result
    • applyPartial

      default LongSupplier applyPartial​(long t)
      Partially apply a parameter such that a single param function becomes a no-param supplier.
      Specified by:
      applyPartial in interface LongFunction<Long>
      Parameters:
      t - The parameter to apply.
      Returns:
      A partially-applied function.
    • consume

      default LongConsumer consume​(LongConsumer consumer)
      Consume a function.
      Specified by:
      consume in interface ToLongFunction<Long>
      Parameters:
      consumer - The consumer to use in consuming.
      Returns:
      A Consumer which passes it's argument to this function and then passes the result into the given consumer.
    • mapToObj

      default <S> LongFunction<S> mapToObj​(LongFunction<? extends S> functor)
      Lift a function.
      Specified by:
      mapToObj in interface ToLongFunction<Long>
      Type Parameters:
      S - The return type.
      Parameters:
      functor - The function to use in lifting.
      Returns:
      A function that passes the result of fn through a functor to produce a lifted function.
    • mapToPredicate

      default LongPredicate mapToPredicate​(LongPredicate functor)
      Lift a function.
      Specified by:
      mapToPredicate in interface ToLongFunction<Long>
      Parameters:
      functor - The function to use in lifting.
      Returns:
      A function that passes the result of fn through a functor to produce a lifted function.
    • mapToDouble

      default LongToDoubleFunction mapToDouble​(LongToDoubleFunction functor)
      Lift a function.
      Specified by:
      mapToDouble in interface ToLongFunction<Long>
      Parameters:
      functor - The function to use in lifting.
      Returns:
      A function that passes the result of fn through a functor to produce a lifted function.
    • mapToInt

      default LongToIntFunction mapToInt​(LongToIntFunction functor)
      Lift a function.
      Specified by:
      mapToInt in interface ToLongFunction<Long>
      Parameters:
      functor - The function to use in lifting.
      Returns:
      A function that passes the result of fn through a functor to produce a lifted function.
    • map

      default LongUnaryOperator map​(UnaryOperator<Long> functor)
      Lift a function.
      Specified by:
      map in interface UnaryOperator<Long>
      Parameters:
      functor - The function to use in lifting.
      Returns:
      A function that passes the result of fn through a functor to produce a lifted function.
    • recurse

      default long recurse​(long value, LongPredicate terminalCondition)
      A method that tells a function to call itself with its own result. This actually imitates recursion using iteration. Don't tell anyone.
      Parameters:
      value - The initial value to apply to the function.
      terminalCondition - The condition upon which the "recursion" will terminate.
      Returns:
      The result of the recursive call.
    • recurse

      default long recurse​(long value, LongPredicate terminalCondition, int maxDepth)
      A method that tells a function to call itself with its own result. This actually imitates recursion using iteration. Don't tell anyone.
      Parameters:
      value - The initial value to apply to the function.
      terminalCondition - The condition upon which the "recursion" will terminate.
      maxDepth - The maximum number of times to recurse. A depth of zero or less will simply return the passed-in value (the function will never be called).
      Returns:
      The result of the recursive call.
    • recurse

      default long recurse​(long value, int depth)
      A method that tells a function to call itself with its own result. This actually imitates recursion using iteration. Don't tell anyone.
      Parameters:
      value - The initial value to apply to the function.
      depth - The number of times to recurse. A depth of zero or less will simply return the passed-in value (the function will never be called).
      Returns:
      The result of the recursive call.
    • recursive

      default LongUnaryOperator recursive​(LongPredicate terminalCondition)
      A method that creates a function which calls a function with its own result until some condition is met.
      Parameters:
      terminalCondition - The condition upon which the recursion will terminate.
      Returns:
      A function that will call the given function on its own result a number of times as specified by the depth parameter.
    • recursive

      default LongUnaryOperator recursive​(LongPredicate terminalCondition, int maxDepth)
      A method that creates a function which calls a function with its own result some amount of times or until some condition is met.
      Parameters:
      terminalCondition - The condition upon which the recursion will terminate.
      maxDepth - The maximum number of times to recurse. A depth of zero or less will simply return the passed-in value (the function will never be called).
      Returns:
      A function that will call the given function on its own result a number of times as specified by the depth parameter.
    • recursive

      default LongUnaryOperator recursive​(int depth)
      A method that creates a function which calls a function with its own result some amount of times.
      Specified by:
      recursive in interface UnaryOperator<Long>
      Parameters:
      depth - The number of times to recurse. A depth of zero or less will simply return the value passed to apply(t) (the inner function will never be called).
      Returns:
      A function that will call the given function on its own result a number of times as specified by the depth parameter.
    • identity

      static LongUnaryOperator identity()
      Returns a unary operator that always returns its input argument.
      Returns:
      a unary operator that always returns its input argument