![JAR search and dependency download from the Maven repository](/logo.png)
spoon.examples.factory.src.Main Maven / Gradle / Ivy
The newest version!
package spoon.examples.factory.src;
import spoon.examples.factory.src.impl1.BImpl1;
import spoon.examples.factory.src.impl1.FactoryImpl1;
import spoon.examples.factory.src.impl2.FactoryImpl2;
public class Main {
public static void main(String[] args) {
execute(new FactoryImpl1());
execute(new FactoryImpl2());
}
public static void execute(Factory f) {
System.out.println("======= running program with factory "+f);
A a = f.createA();
a.m1();
B b = f.createB();
b.m2();
// that's a mistake: the factory should be used!
new BImpl1().m2();
// non-factory instantiation
new Object();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy