@@ -0,0 +1,1957 @@
+package total;%0A%0Aimport java.util.Arrays;%0Aimport java.util.List;%0Aimport java.util.Optional;%0A%0Apublic class Total %7B%0A    static final List%3CPair%3CInteger, Integer%3E%3E pairs = Arrays.asList(%0A        Pair.of(6, 2),%0A        Pair.of(2, 6),%0A        Pair.of(2, 0),%0A        Pair.of(2, 8)%0A    );%0A%0A    private static int percent(int a, int b) %7B%0A        return a * 100 / b;%0A    %7D%0A%0A    private static int percent(Pair%3CInteger, Integer%3E pair) %7B%0A        return percent(pair.left, pair.right);%0A    %7D%0A%0A    private static Optional%3CInteger%3E percentOptional(int a, int b) %7B%0A        if (b == 0) %7B%0A            return Optional.empty();%0A        %7D else %7B%0A            return Optional.of(a * 100 / b);%0A        %7D%0A    %7D%0A%0A    private static Optional%3CInteger%3E percentOptional(Pair%3CInteger, Integer%3E pair) %7B%0A        return percentOptional(pair.left, pair.right);%0A    %7D%0A%0A    private static int percentStrict(int a, NotZeroInt b) %7B%0A        return a * 100 / b.number;%0A    %7D%0A%0A    private static int percentStrict(Pair%3CInteger, NotZeroInt%3E pair) %7B%0A        return percentStrict(pair.left, pair.right);%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        pairs.stream()%0A            .map(pair -%3E %7B%0A                try %7B%0A                    return Optional.of(Total.percent(pair));%0A                %7D catch (ArithmeticException e) %7B%0A                    return Optional.empty();%0A                %7D%0A            %7D)%0A            .forEach(System.out::println);%0A%0A        pairs.stream()%0A            .map(Total::percentOptional)%0A            .forEach(System.out::println);%0A%0A        pairs.stream()%0A            .map(pair -%3E pair.rightOptMap(NotZeroInt::of))%0A            .map(pairOpt -%3E pairOpt.map(Total::percentStrict))%0A            .forEach(System.out::println);%0A%0A        pairs.stream()%0A            .map(pair -%3E pair.rightOptMap(NotZeroInt::of))%0A            .filter(Optional::isPresent)%0A            .map(Optional::get)%0A            .map(Total::percentStrict)%0A            .forEach(System.out::println);%0A    %7D%0A%7D%0A

Add sample usage of total functions