void (String[] args) { Foo<String, IllegalArgumentException> foo = new Foo<>(new HashMap<String, IllegalArgumentException>()); System.out.println(foo); HashMap<Integer, IllegalStateException> hashMap = new HashMap<>(); Foo<Integer, IllegalStateException> myFoo = Foo.of(hashMap); Map<Integer, IllegalStateException> bar = myFoo.buildBar(); System.out.println(bar); Foo<Integer, NullPointerException> exceptionFoo = Foo.of(new HashMap<Integer, NullPointerException>()); System.out.println(exceptionFoo.buildBar()); }