0

Trying to make my project independant of Edge and Nodetype I am using as much generics as possible, however when instantiating a new Graph in order to provide an edgetype I followed this: How to get a class instance of generics type T

Problem I get an error:

Exception in thread "main" java.lang.RuntimeException: Supplier failed at org.jgrapht.util.SupplierUtil.lambda$createSupplier$32fc57c8$1(SupplierUtil.java:64) at org.jgrapht.graph.AbstractBaseGraph.addEdge(AbstractBaseGraph.java:246) at perspective.StructureMap.investigateGraph(StructureMap.java:54)

StructureData<V, E> struc=new StructureData<V, E>(cls);
struc.g.addEdge(knot,nachb);

public class StructureData<V, E> {

private Class<E> cls;
public StructureData(Class<E> cls)
{
    this.cls=cls;
}
//public SimpleDirectedGraph<Object,Edge> g= new SimpleDirectedGraph<Object,Edge>(Edge.class);
public SimpleDirectedGraph<Object,E> g= new SimpleDirectedGraph<Object,E>(cls);
public Map<V,V> excluded= new HashMap<V,V>();
public Set<PlaceholderNode> substitutes=new HashSet<PlaceholderNode>();
public HashMap<Object,Integer> generation=new HashMap<Object,Integer>();
public HashMap<Object,Integer> branch=new HashMap<Object,Integer>();
public HashMap<Object,Object> previous=new HashMap<Object,Object>();
}
Sven Heinz
  • 51
  • 8
  • Post a https://stackoverflow.com/help/mcve Most likely the issue is in your custom `Edge` definition. Did you implement a suplier for this edge class? Or does it extend the DefaultEdge class? – Joris Kinable Mar 01 '19 at 08:32
  • No but I tried extending the Defaultedge, which did not change the outcome. Also in the version I put in comments there were no problems, only when using generics. – Sven Heinz Mar 01 '19 at 17:07

0 Answers0