Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. public class FooFactory {
  2.  
  3.     public static FooFactory instance = new FooFactory();
  4.     private java.util.HashMap<Class, Foo> list;
  5.  
  6.     private FooFactory() {
  7.         list = new java.util.HashMap<Class, Foo>();
  8.     }
  9.  
  10.     public static FooFactory getInstance() {
  11.         return instance;
  12.     }
  13.  
  14.     public Foo getFoo(java.lang.Class cls) {
  15.  
  16.         if (!list.containsKey(cls)) {
  17.             list.put(cls, new Foo<cls>());
  18.         }
  19.  
  20.         return list.get(cls);
  21.     }
  22. }
  23.  
  24. class Foo<T> {
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement