Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add empty immutable graph factories #3966

Open
JakeWharton opened this issue Jul 15, 2020 · 2 comments
Open

Add empty immutable graph factories #3966

JakeWharton opened this issue Jul 15, 2020 · 2 comments

Comments

@JakeWharton
Copy link

JakeWharton commented Jul 15, 2020

I'm having to do things like

ImmutableGraph.copyOf(GraphBuilder.directed().build<String>())

in order to practice the null-object pattern rather than use null for default values of graph properties.

It would be nice to have empty() or of() factories for an immutable version of a graph/value graph/network for this reason.

@netdpb
Copy link
Member

netdpb commented Jul 16, 2020

I think the intended pattern is the following, which is still not as simple as it could be for empty graphs, but it's simpler than what you have.

GraphBuilder.directed().<Foo>immutable().build() // Java
GraphBuilder.directed().immutable<Foo>().build() // Kotlin

@JakeWharton
Copy link
Author

Ah, I don't have an immutable(). I think I need a version bump! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants