question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GraphBuilder.directed() and GraphBuilder.undirected() should not be parameterized on Object

See original GitHub issue

I feel like I must be missing something, but I can’t figure out at all why these methods don’t look like:

public static <N> GraphBuilder<N> directed() { ... }
public static <N> GraphBuilder<N> undirected() { ... }

The current design means that it’s not possible to get a GraphBuilder parameterized on anything besides Object using these patterns until you call nodeOrder, which will properly infer the generic type and perform a cast. (Incidentally, it feels strange that nodeOrder has this generic downcasting behavior but, e.g., allowsSelfLoops does not.)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jrtomcommented, Oct 18, 2018

I’ve got an update to the docs out for review now, so it should hopefully be in the next release of Guava.

Thanks for encouraging us to improve our documentation. 😃

0reactions
jrtomcommented, Oct 18, 2018

Yup, the change covers them too, but thanks for asking. 😃
It also mentions that the types do get specified (i.e., don’t start out as Object) if you create a *Builder using the from() static method.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphBuilder (Guava: Google Core Libraries for Java 20.0 API)
A builder for constructing instances of MutableGraph with user-defined properties. A graph built by this class will have the following properties by default:....
Read more >
Graph (Guava: Google Core Libraries for Java 23.6-jre API)
Returns the count of node 's outgoing edges (equal to successors(node).size() ) in a directed graph. In an undirected graph, returns the degree(Object)...
Read more >
GraphTypeBuilder (JGraphT : a free Java graph library)
A builder class for the hierarchy of Graph s that the library provides. The following example creates a directed graph which allows multiple...
Read more >
com.google.common.truth.IterableSubject.hasSize java code ...
asList().hasSize(1); TypeVariable<?> captured = (TypeVariable<?>) typeArgs[0]; assertThat(captured.getBounds()).asList().containsExactly(Object.class); ...
Read more >
guava/guava-tests/test/com/google/common/graph ... - Program Talk
you may not use this file except in compliance with the License. ... add parameters: directed/undirected ... return GraphBuilder.undirected().build();.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found