'What is the smartest way to change functional interfaces method name?

Somehow I have some requirements to use all benefit of pre-written default methods and change the abstract method(apply(T t)) from Java Function<T, R>.

If I choose to make new @FunctionalInterface extends Function<T, R>, and the method name will be operate(T t), I guess my code will be like below,

@FucntionalInterface
public interface CustomOperator<T, R> extends Function<T, R>{

  R operate(T t);
  
  @override
  default R apply(T t){
    //do something
  } 
}

Let's say all of the client codes which use CustomeOperator only call operate(T t), and if I want the interface to have all the same benefits that the default methods of Function<T ,R> already provide, What is the best approach for filling in the "//do something" parts?

of I want to know whether inheritance is not the smartest(or possible) way for my requirement or not.



Solution 1:[1]

There is only one reasonable implementation:

@Override
default R apply(T t) {
  return operate(t);
}

...and it's perfectly normal to do it that way.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Louis Wasserman