我的问题是如何通过没有名称的Factory方法访问实例cretead 这是我的代码
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实例?