default <OTHER> RugalFunction<OTHER, TO> compose(RugalFunction<? super OTHER, ? extends FROM> before) { Objects.requireNonNull(before); System.out.println("Do that first and then do this"); return (OTHER v) -> this.apply(before.apply(v)); }
default <OTHER> RugalFunction<FROM, OTHER> andThen(RugalFunction<? super TO, ? extends OTHER> after) { Objects.requireNonNull(after); System.out.println("Do this and then do that"); return (FROM f) -> after.apply(this.apply(f)); } }
RugalFunction<String, Integer> rf = a -> Integer.parseInt(a); RugalFunction<String, Float> call = rf.andThen((Integer b) -> b * 1.0F); System.out.println(call.apply("1")); /* --- exec-maven-plugin:1.2.1:exec (default-cli) @ functional --- Do this and then do that 1.0 */