Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.reflect.Constructor;
- import java.util.Collection;
- public class CollectionFactory<T> implements ICollectionFactory<T> {
- Constructor<T> consruct;
- public CollectionFactory()
- {
- }
- @Override
- public Collection<T> getInstance(CollectionType type) {
- try {
- Constructor<Collection<T>> constructor = (Constructor<Collection<T>>) type.getCollectionClass().getConstructor();
- return constructor.newInstance();
- } catch (Exception e) {
- throw new InternalError();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement