create generic graph avoid instanceof


Hello everybody,

I was looking for javafx implementation of graphs, here, but for the id, I would like to have any type. The problem is that when I want to show it, It depends of the type, so I can do this :

public class LabelCell<T> extends Cell<T> {

public LabelCell(T id) {
    Pane pane=new Pane();
    Label view;

    if (id instanceof SQLTableVertex) {

     String labelString="";

     labelString+=((SQLTableVertex) id).getName();
     for (Identifier i:((SQLTableVertex) id).getIdentifiers())
         labelString+= "\n" +i;

     view = new Label(labelString);


        view=new Label(id.toString());

    view.setStyle("-fx-background-color: lightgray;");


But I lose the fact that it's generic. I could also add a case in the switch of the model but it is the same problem

How can I deal with it ? Thank's by advance.

Show source
| generics   | java   | graph   2016-12-18 13:12 0 Answers

Answers to create generic graph avoid instanceof ( 0 )

Leave a reply to - create generic graph avoid instanceof

◀ Go back