[ https://issues.apache.org/jira/browse/FLINK-4440?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15431625#comment-15431625 ]
Ivan Mushketyk commented on FLINK-4440: --------------------------------------- [~greghogan] On the second thought, We can define a static function in a following way: {code:java} public static <K> Vertex<K, NullValue> create(K id) { return new Vertex<>(id, NullValue.getInstance()); } {code} guaranteeing that value type is NullValue, but we cannot define a constructor in a similar fashion. We can cast NullValue.getInstance() to value type like: {code:java} public Vertex(K id) { super(id, (V) NullValue.getInstance()); } {code} but then a user can write code like: {code:java} Vertex<Integer, String> vertex = new Vertex<>(1); String str = vertex.getValue(); // ClassCastException {code} While similar code with a static function would not even compile {code:java} Vertex<Integer, String> vertex = Vertex.create(1); // compilation error {code} > Make API for edge/vertex creation less verbose > ---------------------------------------------- > > Key: FLINK-4440 > URL: https://issues.apache.org/jira/browse/FLINK-4440 > Project: Flink > Issue Type: Improvement > Components: Gelly > Reporter: Ivan Mushketyk > Assignee: Ivan Mushketyk > Priority: Trivial > > It would be better if one could create vertex/edges like this: > {code:java} > Vertex<Integer, NullValue> v = Vertex.create(42); > Edge<Integer, Integer, NullValue> e = Edge.create(5, 6); > {code} > Instead of this: > {code:java} > Vertex<Integer, NullValue> v = new Vertex<Integer, NullValue>(42, > NullValue.getInstance()); > Edge<Integer, Integer, NullValue> e = new Edge<Integer, Integer, > NullValue>(5, 6, NullValue.getInstance()); > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)