MentaContainer

Compare Revisions

Ignore whitespace Rev 146 → Rev 147

/trunk/src/test/java/org/mentacontainer/impl/WrapperFactoryTest.java
13,7 → 13,7
String s = new String("saoj");
Factory ic = new WrapperFactory(s);
Factory ic = new SingletonFactory(s);
Container c = new MentaContainer();
/trunk/src/main/java/org/mentacontainer/impl/WrapperFactory.java
File deleted
\ No newline at end of file
/trunk/src/main/java/org/mentacontainer/impl/SingletonFactory.java
New file
0,0 → 1,30
package org.mentacontainer.impl;
 
import org.mentacontainer.Factory;
 
public class SingletonFactory implements Factory {
private final Object instance;
private final Class<? extends Object> type;
public SingletonFactory(Object instance) {
 
this.instance = instance;
this.type = instance.getClass();
}
@Override
public <T> T getInstance() {
return (T) instance;
}
@Override
public Class<? extends Object> getType() {
return type;
}
}