Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. import java.lang.reflect.Constructor;
  2. import java.util.Collection;
  3.  
  4. public class CollectionFactory<T> implements ICollectionFactory<T> {
  5.     Constructor<T> consruct;
  6.  
  7.     public CollectionFactory()
  8.     {
  9.        
  10.     }
  11.  
  12.     @Override
  13.     public Collection<T> getInstance(CollectionType type) {
  14.         try {
  15.             Constructor<Collection<T>> constructor = (Constructor<Collection<T>>) type.getCollectionClass().getConstructor();
  16.             return constructor.newInstance();
  17.         } catch (Exception e) {
  18.             throw new InternalError();
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement