Я пытаюсь реализовать шаблон проектирования трубопровода, используя Java 8 со следующей статьей для моей справки:
{ ссылка }
Код:
public abstract class Pipeline{
Function<Integer, Integer> addOne = it -> {
System.out.println(it + 1);
return it + 1;
};
Function<Integer, Integer> addTwo = it -> {
System.out.println(it + 2);
return it + 2;
};
Function<Integer, Integer> timesTwo = input -> {
System.out.println(input * 2);
return input * 2;
};
final Function<Integer, Integer> pipe = sourceInt
.andThen(timesTwo)
.andThen(addOne)
.andThen(addTwo);
}
Я пытаюсь добавить один абстрактный метод и хочу переопределить его. Я пытаюсь сделать что-то вроде:
abstract BiFunction<Integer, Integer,Integer> overriden;
и изменить канал на:
final Function<Integer, Integer> pipe = sourceInt
.andThen(timesTwo)
.andThen(overriden)
.andThen(addOne)
.andThen(addTwo);
}
Но проблема в том, что я не знаю, объявить Function<Integer, Integer>
как абстрактный метод.