blob: 225690c18bd11203afc7ddb1a0583e49a59149ed [file] [log] [blame]
tome3489412014-08-29 02:30:38 -07001package org.onlab.graph;
2
3import java.util.Objects;
4
tom144de692014-08-29 11:38:44 -07005import static com.google.common.base.Objects.toStringHelper;
6
tome3489412014-08-29 02:30:38 -07007/**
8 * Test edge.
9 */
10public class TestEdge extends AbstractEdge<TestVertex> {
11
12 private final double weight;
13
14 /**
15 * Creates a new edge between the specified source and destination vertexes.
16 *
17 * @param src source vertex
18 * @param dst destination vertex
19 * @param weight edge weight
20 */
21 public TestEdge(TestVertex src, TestVertex dst, double weight) {
22 super(src, dst);
23 this.weight = weight;
24 }
25
26 /**
27 * Returns the edge weight.
28 *
29 * @return edge weight
30 */
31 public double weight() {
32 return weight;
33 }
34
35 @Override
36 public int hashCode() {
37 return 31 * super.hashCode() + Objects.hash(weight);
38 }
39
40 @Override
41 public boolean equals(Object obj) {
42 if (obj instanceof TestEdge) {
43 final TestEdge other = (TestEdge) obj;
44 return super.equals(obj) && Objects.equals(this.weight, other.weight);
45 }
46 return false;
47 }
tom144de692014-08-29 11:38:44 -070048
49 @Override
50 public String toString() {
51 return toStringHelper(this).add("src", src()).add("dst", dst()).
52 add("weight", weight).toString();
53 }
54
tome3489412014-08-29 02:30:38 -070055}