@@ -0,0 +1,870 @@
+package org.whirlwin.java8.examples.misc;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0Aimport java.util.Optional;%0A%0Apublic class OptionalExample %7B%0A%0A    private static final Map%3CInteger, String%3E nameRegistry = new HashMap%3CInteger, String%3E() %7B%7B%0A        put(1, %22John Doe%22);%0A    %7D%7D;%0A%0A    public static void main(String%5B%5D args) %7B%0A        Optional%3CString%3E johnDoe = getNameById(1);%0A        printName(johnDoe);%0A%0A        Optional%3CString%3E janeDoe = getNameById(2);%0A        printName(janeDoe);%0A    %7D%0A%0A    public static Optional%3CString%3E getNameById(int id) %7B%0A        String name = nameRegistry.get(id);%0A        return Optional.ofNullable(name);%0A    %7D%0A%0A    public static void printName(Optional%3CString%3E name) %7B%0A        if (name.isPresent()) %7B%0A            System.out.println(name.get());%0A        %7D else %7B%0A            System.out.println(%22Warning: Name not set%22);%0A        %7D%0A    %7D%0A%7D%0A

Add Optional example.