Code Review
/
yangtools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Use Objects.hashCode()
[yangtools.git]
/
yang
/
yang-parser-impl
/
src
/
main
/
java
/
org
/
opendaylight
/
yangtools
/
yang
/
parser
/
util
/
TopologicalSort.java
diff --git
a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/TopologicalSort.java
b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/TopologicalSort.java
index 105e2978910d18a52b1cb11d62d05ec4242c37b4..42db14607eed2e7b4d20dda9bd9156b99050a1e1 100644
(file)
--- a/
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/TopologicalSort.java
+++ b/
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/TopologicalSort.java
@@
-11,6
+11,7
@@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.util.List;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
/**
import java.util.Set;
/**
@@
-26,7
+27,8
@@
public final class TopologicalSort {
/**
* Topological sort of dependent nodes in acyclic graphs.
/**
* Topological sort of dependent nodes in acyclic graphs.
- *
+ *
+ * @param nodes graph nodes
* @return Sorted {@link List} of {@link Node}s. Order: Nodes with no
* dependencies starting.
* @throws IllegalStateException
* @return Sorted {@link List} of {@link Node}s. Order: Nodes with no
* dependencies starting.
* @throws IllegalStateException
@@
-61,7
+63,7
@@
public final class TopologicalSort {
private static Set<Node> getDependentNodes(Set<Node> nodes) {
Set<Node> dependentNodes = Sets.newHashSet();
for (Node n : nodes) {
private static Set<Node> getDependentNodes(Set<Node> nodes) {
Set<Node> dependentNodes = Sets.newHashSet();
for (Node n : nodes) {
- if (n.getOutEdges().
size() == 0
) {
+ if (n.getOutEdges().
isEmpty()
) {
dependentNodes.add(n);
}
}
dependentNodes.add(n);
}
}
@@
-108,6
+110,11
@@
public final class TopologicalSort {
private final Set<Edge> inEdges;
private final Set<Edge> outEdges;
private final Set<Edge> inEdges;
private final Set<Edge> outEdges;
+ public NodeImpl() {
+ inEdges = Sets.newHashSet();
+ outEdges = Sets.newHashSet();
+ }
+
@Override
public Set<Edge> getInEdges() {
return inEdges;
@Override
public Set<Edge> getInEdges() {
return inEdges;
@@
-123,11
+130,6
@@
public final class TopologicalSort {
outEdges.add(e);
to.getInEdges().add(e);
}
outEdges.add(e);
to.getInEdges().add(e);
}
-
- public NodeImpl() {
- inEdges = Sets.newHashSet();
- outEdges = Sets.newHashSet();
- }
}
/**
}
/**
@@
-137,6
+139,11
@@
public final class TopologicalSort {
private final Node from;
private final Node to;
private final Node from;
private final Node to;
+ public EdgeImpl(Node from, Node to) {
+ this.from = from;
+ this.to = to;
+ }
+
@Override
public Node getFrom() {
return from;
@Override
public Node getFrom() {
return from;
@@
-147,18
+154,12
@@
public final class TopologicalSort {
return to;
}
return to;
}
- public EdgeImpl(Node from, Node to) {
- this.from = from;
- this.to = to;
-
- }
-
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result +
((from == null) ? 0 : from.hashCode()
);
- result = prime * result +
((to == null) ? 0 : to.hashCode()
);
+ result = prime * result +
Objects.hashCode(from
);
+ result = prime * result +
Objects.hashCode(to
);
return result;
}
return result;
}