@@ -0,0 +1,1594 @@
+import java.util.ArrayList;%0Aimport java.util.HashMap;%0A%0A/**%0A * Created by Velik Georgiev on 11/3/2017.%0A */%0A%0Apublic class LTPExample %7B%0A    public String name;%0A%0A    public  LTPExample(String name) %7B%0A        this.name = name;%0A%0A        InstanceRegister.append(LTPExample.class, this);%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        LTPExample example1 = new LTPExample(%22ex1%22);%0A        LTPExample example2 = new LTPExample(%22ex2%22);%0A        LTPExample example3 = new LTPExample(%22ex3%22);%0A%0A        InstanceRegister.getInstances(LTPExample.class).forEach(v -%3E %7B%0A            System.out.println(((LTPExample) v).name);%0A        %7D);%0A    %7D%0A%7D%0A%0Aclass InstanceRegister %7B%0A    private final static HashMap%3CString, ArrayList%3CObject%3E%3E instancesRegistry = new HashMap%3C%3E();%0A%0A    public static void append(Class%3C?%3E clazz, final Object instance) %7B%0A        String className = clazz.getClass().getName();%0A        ArrayList%3CObject%3E container;%0A%0A        if (instancesRegistry.containsKey(className)) %7B%0A            container = instancesRegistry.get(className);%0A            container.add(instance);%0A        %7D else %7B%0A            container = new ArrayList%3CObject%3E() %7B%7B add(instance); %7D%7D;%0A            instancesRegistry.put(className, container);%0A        %7D%0A    %7D%0A%0A    public static ArrayList%3CObject%3E getInstances(Class%3C?%3E clazz) %7B%0A        String className = clazz.getClass().getName();%0A%0A        if (!instancesRegistry.containsKey(className)) %7B%0A            return null;%0A        %7D%0A%0A        return instancesRegistry.get(className);%0A    %7D%0A%0A    public static void clearRegistry() %7B%0A        instancesRegistry.clear();%0A    %7D%0A%7D%0A

Create LTPExample.java