我的问题是如何通过没有名称的工厂方法访问实例创建这是我的代码
public abstract class Vertex <T>{
int vertexId ;
T vertexValue ;
public abstract T computeVertexValue();}
public class ImageVertex extends Vertex<Map<String, Instance>>{
public ImageVertex(int id ) {
this.vertexId=id;
}
@Override
public Map<String, Instance> computeVertexValue() {
//
}
public abstract class AbstractVertexFactory<T extends Vertex> {
public abstract T createVertex(int id);}
public class ImageFactory extends AbstractVertexFactory<ImageVertex> {
@Override
public ImageVertex createVertex(int id) {
// TODO Auto-generated method stub
ImageVertex imVertex=new ImageVertex(id);
imVertex.computeVertexValue();
return imVertex;
}}
public class ImageFactorySimulator {
public static void main(String[] args) {
AbstractVertexFactory<ImageVertex> immFactory = new ImageFactory();
ImageVertex imVertex = immFactory.createVertex(1);}}
如何从模拟器类或任何其他类访问 id 等于 1 的 ImageVertex 实例?