Skip to content

Commit

Permalink
{*Graph, Network}.java: change documentation of allowsSelfLoops() and…
Browse files Browse the repository at this point in the history
… allowsParallelEdges() to correct the type of exception that is thrown when one attempts to modify them in a way that the constraint prevents (e.g., adding a self-loop to a graph that doesn't allow them).

Technically this is a contract change, but in fact the implementations were already throwing IllegalArgumentException, so in practice anyone that was depending on that documentation being accurate (by, say, catching UnsupportedOperationException) was already in trouble, so IMO we should just make this change without trying to worry about backward compatibility; this is just a bug fix.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=147933338
  • Loading branch information
jrtom authored and cpovirk committed Feb 21, 2017
1 parent 891d64b commit 717ece9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion guava/src/com/google/common/graph/BaseGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ interface BaseGraph<N> extends SuccessorGraph<N>, PredecessorGraph<N> {
/**
* Returns true if this graph allows self-loops (edges that connect a node to itself). Attempting
* to add a self-loop to a graph that does not allow them will throw an {@link
* UnsupportedOperationException}.
* IllegalArgumentException}.
*/
boolean allowsSelfLoops();

Expand Down
4 changes: 2 additions & 2 deletions guava/src/com/google/common/graph/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ public interface Network<N, E> extends SuccessorGraph<N>, PredecessorGraph<N> {

/**
* Returns true if this network allows parallel edges. Attempting to add a parallel edge to a
* network that does not allow them will throw an {@link UnsupportedOperationException}.
* network that does not allow them will throw an {@link IllegalArgumentException}.
*/
boolean allowsParallelEdges();

/**
* Returns true if this network allows self-loops (edges that connect a node to itself).
* Attempting to add a self-loop to a network that does not allow them will throw an {@link
* UnsupportedOperationException}.
* IllegalArgumentException}.
*/
boolean allowsSelfLoops();

Expand Down

0 comments on commit 717ece9

Please sign in to comment.