@@ -0,0 +1,879 @@
+package org.xander.creational.singleton;%0A%0Aimport java.util.function.UnaryOperator;%0A%0Apublic class GeneralSingletonFactoryPattern %7B%0A    private static final UnaryOperator%3CObject%3E IDENTITY_FN = (t) -%3E t;%0A    @SuppressWarnings(%22unchecked%22)%0A    public static %3CT%3E UnaryOperator%3CT%3E identityFunction() %7B return (UnaryOperator%3CT%3E) IDENTITY_FN;%0A    %7D%0A%0A    // Sample program to exercise generic singleton%0A    public static void main(String%5B%5D args) %7B%0A        String%5B%5D strings = %7B %22jute%22, %22hemp%22, %22nylon%22 %7D;%0A        UnaryOperator%3CString%3E sameString = identityFunction();%0A%0A        for (String s : strings) %7B%0A            System.out.println(sameString.apply(s));%0A        %7D%0A        %0A        Number%5B%5D numbers = %7B 1, 2.0, 3L %7D;%0A        UnaryOperator%3CNumber%3E sameNumber = identityFunction();%0A%0A        for (Number n : numbers) %7B%0A            System.out.println(sameNumber.apply(n));%0A        %7D%0A    %7D%0A%7D%0A

add general singleton factory pattern