HIGUCHI Yuta
Committed by Gerrit Code Review

Avoid use of Objects.hash when there's only 1 params

- directly call #hashCode() when hashed Object seems non-null
- replace with Objects.hashCode(Object) when Nullable
- replace with Long.hashCode(long), etc. when primitive

Change-Id: I08c24ebbe94cf4162d1491209a14baf953163e41
Showing 67 changed files with 124 additions and 247 deletions
...@@ -61,7 +61,7 @@ public class NextHopGroupKey { ...@@ -61,7 +61,7 @@ public class NextHopGroupKey {
61 61
62 @Override 62 @Override
63 public int hashCode() { 63 public int hashCode() {
64 - return Objects.hash(address); 64 + return address.hashCode();
65 } 65 }
66 66
67 @Override 67 @Override
......
...@@ -421,7 +421,7 @@ public class BgpRouteEntry extends RouteEntry { ...@@ -421,7 +421,7 @@ public class BgpRouteEntry extends RouteEntry {
421 421
422 @Override 422 @Override
423 public int hashCode() { 423 public int hashCode() {
424 - return Objects.hash(pathSegments); 424 + return pathSegments.hashCode();
425 } 425 }
426 426
427 @Override 427 @Override
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
17 package org.onosproject.segmentrouting; 17 package org.onosproject.segmentrouting;
18 18
19 import java.util.List; 19 import java.util.List;
20 -import java.util.Objects;
21 -
22 import static com.google.common.base.Preconditions.checkNotNull; 20 import static com.google.common.base.Preconditions.checkNotNull;
23 21
24 /** 22 /**
...@@ -96,7 +94,7 @@ public class DefaultTunnel implements Tunnel { ...@@ -96,7 +94,7 @@ public class DefaultTunnel implements Tunnel {
96 94
97 @Override 95 @Override
98 public int hashCode() { 96 public int hashCode() {
99 - return Objects.hash(labelIds); 97 + return labelIds.hashCode();
100 } 98 }
101 99
102 @Override 100 @Override
......
...@@ -49,7 +49,7 @@ public final class BindingHostId { ...@@ -49,7 +49,7 @@ public final class BindingHostId {
49 49
50 @Override 50 @Override
51 public int hashCode() { 51 public int hashCode() {
52 - return Objects.hash(bindingHostId); 52 + return bindingHostId.hashCode();
53 } 53 }
54 54
55 @Override 55 @Override
......
...@@ -53,7 +53,7 @@ public final class PhysicalNetwork { ...@@ -53,7 +53,7 @@ public final class PhysicalNetwork {
53 53
54 @Override 54 @Override
55 public int hashCode() { 55 public int hashCode() {
56 - return Objects.hash(physicalNetwork); 56 + return physicalNetwork.hashCode();
57 } 57 }
58 58
59 @Override 59 @Override
......
...@@ -52,7 +52,7 @@ public final class SecurityGroup { ...@@ -52,7 +52,7 @@ public final class SecurityGroup {
52 52
53 @Override 53 @Override
54 public int hashCode() { 54 public int hashCode() {
55 - return Objects.hash(securityGroup); 55 + return securityGroup.hashCode();
56 } 56 }
57 57
58 @Override 58 @Override
......
...@@ -53,7 +53,7 @@ public final class SegmentationId { ...@@ -53,7 +53,7 @@ public final class SegmentationId {
53 53
54 @Override 54 @Override
55 public int hashCode() { 55 public int hashCode() {
56 - return Objects.hash(segmentationId); 56 + return segmentationId.hashCode();
57 } 57 }
58 58
59 @Override 59 @Override
......
...@@ -53,7 +53,7 @@ public final class SubnetId { ...@@ -53,7 +53,7 @@ public final class SubnetId {
53 53
54 @Override 54 @Override
55 public int hashCode() { 55 public int hashCode() {
56 - return Objects.hash(subnetId); 56 + return subnetId.hashCode();
57 } 57 }
58 58
59 @Override 59 @Override
......
...@@ -53,7 +53,7 @@ public final class TenantId { ...@@ -53,7 +53,7 @@ public final class TenantId {
53 53
54 @Override 54 @Override
55 public int hashCode() { 55 public int hashCode() {
56 - return Objects.hash(tenantId); 56 + return tenantId.hashCode();
57 } 57 }
58 58
59 @Override 59 @Override
......
...@@ -52,7 +52,7 @@ public final class TenantNetworkId { ...@@ -52,7 +52,7 @@ public final class TenantNetworkId {
52 52
53 @Override 53 @Override
54 public int hashCode() { 54 public int hashCode() {
55 - return Objects.hash(networkId); 55 + return networkId.hashCode();
56 } 56 }
57 57
58 @Override 58 @Override
......
...@@ -46,7 +46,7 @@ public final class VirtualPortId { ...@@ -46,7 +46,7 @@ public final class VirtualPortId {
46 46
47 @Override 47 @Override
48 public int hashCode() { 48 public int hashCode() {
49 - return Objects.hash(portId); 49 + return portId.hashCode();
50 } 50 }
51 51
52 @Override 52 @Override
......
...@@ -245,7 +245,7 @@ public final class ConfigProperty { ...@@ -245,7 +245,7 @@ public final class ConfigProperty {
245 245
246 @Override 246 @Override
247 public int hashCode() { 247 public int hashCode() {
248 - return Objects.hash(name); 248 + return name.hashCode();
249 } 249 }
250 250
251 /** 251 /**
......
...@@ -20,6 +20,7 @@ import org.onlab.packet.IpAddress; ...@@ -20,6 +20,7 @@ import org.onlab.packet.IpAddress;
20 import java.util.Objects; 20 import java.util.Objects;
21 21
22 import static com.google.common.base.MoreObjects.toStringHelper; 22 import static com.google.common.base.MoreObjects.toStringHelper;
23 +import static com.google.common.base.Preconditions.checkNotNull;
23 24
24 /** 25 /**
25 * Default implementation of a controller instance descriptor. 26 * Default implementation of a controller instance descriptor.
...@@ -57,7 +58,7 @@ public class DefaultControllerNode implements ControllerNode { ...@@ -57,7 +58,7 @@ public class DefaultControllerNode implements ControllerNode {
57 * @param tcpPort TCP port 58 * @param tcpPort TCP port
58 */ 59 */
59 public DefaultControllerNode(NodeId id, IpAddress ip, int tcpPort) { 60 public DefaultControllerNode(NodeId id, IpAddress ip, int tcpPort) {
60 - this.id = id; 61 + this.id = checkNotNull(id);
61 this.ip = ip; 62 this.ip = ip;
62 this.tcpPort = tcpPort; 63 this.tcpPort = tcpPort;
63 } 64 }
...@@ -79,7 +80,7 @@ public class DefaultControllerNode implements ControllerNode { ...@@ -79,7 +80,7 @@ public class DefaultControllerNode implements ControllerNode {
79 80
80 @Override 81 @Override
81 public int hashCode() { 82 public int hashCode() {
82 - return Objects.hash(id); 83 + return id.hashCode();
83 } 84 }
84 85
85 @Override 86 @Override
......
...@@ -35,7 +35,7 @@ public class NodeId implements Comparable<NodeId> { ...@@ -35,7 +35,7 @@ public class NodeId implements Comparable<NodeId> {
35 35
36 @Override 36 @Override
37 public int hashCode() { 37 public int hashCode() {
38 - return Objects.hash(id); 38 + return id.hashCode();
39 } 39 }
40 40
41 @Override 41 @Override
......
...@@ -58,7 +58,7 @@ public class DefaultApplicationId implements ApplicationId { ...@@ -58,7 +58,7 @@ public class DefaultApplicationId implements ApplicationId {
58 58
59 @Override 59 @Override
60 public int hashCode() { 60 public int hashCode() {
61 - return Objects.hash(id); 61 + return Short.hashCode(id);
62 } 62 }
63 63
64 @Override 64 @Override
......
...@@ -42,7 +42,7 @@ public class DefaultGroupId implements GroupId { ...@@ -42,7 +42,7 @@ public class DefaultGroupId implements GroupId {
42 42
43 @Override 43 @Override
44 public int hashCode() { 44 public int hashCode() {
45 - return Objects.hash(id); 45 + return id;
46 } 46 }
47 47
48 @Override 48 @Override
......
...@@ -127,7 +127,7 @@ public final class Version { ...@@ -127,7 +127,7 @@ public final class Version {
127 127
128 @Override 128 @Override
129 public int hashCode() { 129 public int hashCode() {
130 - return Objects.hash(format); 130 + return format.hashCode();
131 } 131 }
132 132
133 @Override 133 @Override
......
...@@ -88,7 +88,7 @@ public class DefaultPath extends DefaultLink implements Path { ...@@ -88,7 +88,7 @@ public class DefaultPath extends DefaultLink implements Path {
88 88
89 @Override 89 @Override
90 public int hashCode() { 90 public int hashCode() {
91 - return Objects.hash(links); 91 + return links.hashCode();
92 } 92 }
93 93
94 @Override 94 @Override
......
...@@ -75,7 +75,7 @@ public final class DeviceId extends ElementId { ...@@ -75,7 +75,7 @@ public final class DeviceId extends ElementId {
75 75
76 @Override 76 @Override
77 public int hashCode() { 77 public int hashCode() {
78 - return Objects.hash(str); 78 + return str.hashCode();
79 } 79 }
80 80
81 @Override 81 @Override
......
...@@ -52,7 +52,7 @@ public final class BridgeName { ...@@ -52,7 +52,7 @@ public final class BridgeName {
52 52
53 @Override 53 @Override
54 public int hashCode() { 54 public int hashCode() {
55 - return Objects.hash(name); 55 + return name.hashCode();
56 } 56 }
57 57
58 @Override 58 @Override
......
...@@ -516,7 +516,7 @@ public final class Instructions { ...@@ -516,7 +516,7 @@ public final class Instructions {
516 516
517 @Override 517 @Override
518 public int hashCode() { 518 public int hashCode() {
519 - return Objects.hash(type().ordinal()); 519 + return type().ordinal();
520 } 520 }
521 521
522 @Override 522 @Override
...@@ -550,7 +550,7 @@ public final class Instructions { ...@@ -550,7 +550,7 @@ public final class Instructions {
550 550
551 @Override 551 @Override
552 public int hashCode() { 552 public int hashCode() {
553 - return Objects.hash(type().ordinal()); 553 + return type().ordinal();
554 } 554 }
555 555
556 @Override 556 @Override
......
...@@ -114,7 +114,7 @@ public abstract class L0ModificationInstruction implements Instruction { ...@@ -114,7 +114,7 @@ public abstract class L0ModificationInstruction implements Instruction {
114 114
115 @Override 115 @Override
116 public int hashCode() { 116 public int hashCode() {
117 - return Objects.hash(lambda); 117 + return lambda.hashCode();
118 } 118 }
119 119
120 @Override 120 @Override
......
...@@ -62,7 +62,7 @@ public abstract class L1ModificationInstruction implements Instruction { ...@@ -62,7 +62,7 @@ public abstract class L1ModificationInstruction implements Instruction {
62 62
63 @Override 63 @Override
64 public int hashCode() { 64 public int hashCode() {
65 - return Objects.hash(oduSignalId); 65 + return oduSignalId.hashCode();
66 } 66 }
67 67
68 @Override 68 @Override
......
...@@ -186,7 +186,7 @@ public class DefaultGroup extends DefaultGroupDescription ...@@ -186,7 +186,7 @@ public class DefaultGroup extends DefaultGroupDescription
186 */ 186 */
187 @Override 187 @Override
188 public int hashCode() { 188 public int hashCode() {
189 - return super.hashCode() + Objects.hash(id); 189 + return Objects.hash(super.hashCode(), id);
190 } 190 }
191 191
192 /* 192 /*
......
...@@ -87,7 +87,7 @@ public final class BandwidthConstraint extends BooleanConstraint { ...@@ -87,7 +87,7 @@ public final class BandwidthConstraint extends BooleanConstraint {
87 87
88 @Override 88 @Override
89 public int hashCode() { 89 public int hashCode() {
90 - return Objects.hash(bandwidth); 90 + return bandwidth.hashCode();
91 } 91 }
92 92
93 @Override 93 @Override
......
...@@ -69,7 +69,7 @@ public class LambdaConstraint extends BooleanConstraint { ...@@ -69,7 +69,7 @@ public class LambdaConstraint extends BooleanConstraint {
69 69
70 @Override 70 @Override
71 public int hashCode() { 71 public int hashCode() {
72 - return Objects.hash(lambda); 72 + return Objects.hashCode(lambda);
73 } 73 }
74 74
75 @Override 75 @Override
......
...@@ -67,7 +67,7 @@ public class LatencyConstraint implements Constraint { ...@@ -67,7 +67,7 @@ public class LatencyConstraint implements Constraint {
67 67
68 @Override 68 @Override
69 public int hashCode() { 69 public int hashCode() {
70 - return Objects.hash(latency); 70 + return latency.hashCode();
71 } 71 }
72 72
73 @Override 73 @Override
......
...@@ -66,7 +66,7 @@ public class ObstacleConstraint extends BooleanConstraint { ...@@ -66,7 +66,7 @@ public class ObstacleConstraint extends BooleanConstraint {
66 66
67 @Override 67 @Override
68 public int hashCode() { 68 public int hashCode() {
69 - return Objects.hash(obstacles); 69 + return obstacles.hashCode();
70 } 70 }
71 71
72 @Override 72 @Override
......
...@@ -91,7 +91,7 @@ public class WaypointConstraint implements Constraint { ...@@ -91,7 +91,7 @@ public class WaypointConstraint implements Constraint {
91 91
92 @Override 92 @Override
93 public int hashCode() { 93 public int hashCode() {
94 - return Objects.hash(waypoints); 94 + return waypoints.hashCode();
95 } 95 }
96 96
97 @Override 97 @Override
......
...@@ -53,7 +53,7 @@ public class BandwidthResourceAllocation implements ResourceAllocation { ...@@ -53,7 +53,7 @@ public class BandwidthResourceAllocation implements ResourceAllocation {
53 53
54 @Override 54 @Override
55 public int hashCode() { 55 public int hashCode() {
56 - return Objects.hash(bandwidth); 56 + return bandwidth.hashCode();
57 } 57 }
58 58
59 @Override 59 @Override
......
...@@ -53,7 +53,7 @@ public class BandwidthResourceRequest implements ResourceRequest { ...@@ -53,7 +53,7 @@ public class BandwidthResourceRequest implements ResourceRequest {
53 53
54 @Override 54 @Override
55 public int hashCode() { 55 public int hashCode() {
56 - return Objects.hash(bandwidth); 56 + return bandwidth.hashCode();
57 } 57 }
58 58
59 @Override 59 @Override
......
...@@ -53,7 +53,7 @@ public class LambdaResourceAllocation implements ResourceAllocation { ...@@ -53,7 +53,7 @@ public class LambdaResourceAllocation implements ResourceAllocation {
53 53
54 @Override 54 @Override
55 public int hashCode() { 55 public int hashCode() {
56 - return Objects.hash(lambda); 56 + return Objects.hashCode(lambda);
57 } 57 }
58 58
59 @Override 59 @Override
......
...@@ -54,7 +54,7 @@ public class MplsLabelResourceAllocation implements ResourceAllocation { ...@@ -54,7 +54,7 @@ public class MplsLabelResourceAllocation implements ResourceAllocation {
54 54
55 @Override 55 @Override
56 public int hashCode() { 56 public int hashCode() {
57 - return Objects.hash(mplsLabel); 57 + return Objects.hashCode(mplsLabel);
58 } 58 }
59 59
60 @Override 60 @Override
......
...@@ -53,7 +53,7 @@ public final class ClusterId { ...@@ -53,7 +53,7 @@ public final class ClusterId {
53 53
54 @Override 54 @Override
55 public int hashCode() { 55 public int hashCode() {
56 - return Objects.hash(id); 56 + return id;
57 } 57 }
58 58
59 @Override 59 @Override
......
...@@ -20,6 +20,7 @@ import org.onosproject.net.Link; ...@@ -20,6 +20,7 @@ import org.onosproject.net.Link;
20 import java.util.Objects; 20 import java.util.Objects;
21 21
22 import static com.google.common.base.MoreObjects.toStringHelper; 22 import static com.google.common.base.MoreObjects.toStringHelper;
23 +import static com.google.common.base.Preconditions.checkNotNull;
23 24
24 /** 25 /**
25 * Implementation of the topology edge backed by a link. 26 * Implementation of the topology edge backed by a link.
...@@ -40,7 +41,7 @@ public class DefaultTopologyEdge implements TopologyEdge { ...@@ -40,7 +41,7 @@ public class DefaultTopologyEdge implements TopologyEdge {
40 public DefaultTopologyEdge(TopologyVertex src, TopologyVertex dst, Link link) { 41 public DefaultTopologyEdge(TopologyVertex src, TopologyVertex dst, Link link) {
41 this.src = src; 42 this.src = src;
42 this.dst = dst; 43 this.dst = dst;
43 - this.link = link; 44 + this.link = checkNotNull(link);
44 } 45 }
45 46
46 @Override 47 @Override
...@@ -60,7 +61,7 @@ public class DefaultTopologyEdge implements TopologyEdge { ...@@ -60,7 +61,7 @@ public class DefaultTopologyEdge implements TopologyEdge {
60 61
61 @Override 62 @Override
62 public int hashCode() { 63 public int hashCode() {
63 - return Objects.hash(link); 64 + return link.hashCode();
64 } 65 }
65 66
66 @Override 67 @Override
......
...@@ -42,7 +42,7 @@ public class DefaultTopologyVertex implements TopologyVertex { ...@@ -42,7 +42,7 @@ public class DefaultTopologyVertex implements TopologyVertex {
42 42
43 @Override 43 @Override
44 public int hashCode() { 44 public int hashCode() {
45 - return Objects.hash(deviceId); 45 + return deviceId.hashCode();
46 } 46 }
47 47
48 @Override 48 @Override
......
...@@ -52,7 +52,7 @@ public class WallClockTimestamp implements Timestamp { ...@@ -52,7 +52,7 @@ public class WallClockTimestamp implements Timestamp {
52 } 52 }
53 @Override 53 @Override
54 public int hashCode() { 54 public int hashCode() {
55 - return Objects.hash(unixTimestamp); 55 + return Long.hashCode(unixTimestamp);
56 } 56 }
57 57
58 @Override 58 @Override
......
...@@ -138,7 +138,7 @@ public class UiView { ...@@ -138,7 +138,7 @@ public class UiView {
138 138
139 @Override 139 @Override
140 public int hashCode() { 140 public int hashCode() {
141 - return Objects.hash(id); 141 + return id.hashCode();
142 } 142 }
143 143
144 @Override 144 @Override
......
...@@ -192,14 +192,17 @@ public class IntentTestsMocks { ...@@ -192,14 +192,17 @@ public class IntentTestsMocks {
192 new MplsLabelResourceAllocation(MplsLabel.valueOf(10))); 192 new MplsLabelResourceAllocation(MplsLabel.valueOf(10)));
193 } 193 }
194 194
195 + @Override
195 public IntentId intentId() { 196 public IntentId intentId() {
196 return null; 197 return null;
197 } 198 }
198 199
200 + @Override
199 public Collection<Link> links() { 201 public Collection<Link> links() {
200 return null; 202 return null;
201 } 203 }
202 204
205 + @Override
203 public Set<ResourceRequest> resources() { 206 public Set<ResourceRequest> resources() {
204 return null; 207 return null;
205 } 208 }
...@@ -408,7 +411,7 @@ public class IntentTestsMocks { ...@@ -408,7 +411,7 @@ public class IntentTestsMocks {
408 411
409 @Override 412 @Override
410 public int hashCode() { 413 public int hashCode() {
411 - return Objects.hash(priority); 414 + return priority;
412 } 415 }
413 416
414 @Override 417 @Override
......
...@@ -51,7 +51,7 @@ public class SystemClockTimestamp implements Timestamp { ...@@ -51,7 +51,7 @@ public class SystemClockTimestamp implements Timestamp {
51 } 51 }
52 @Override 52 @Override
53 public int hashCode() { 53 public int hashCode() {
54 - return Objects.hash(nanoTimestamp); 54 + return Long.hashCode(nanoTimestamp);
55 } 55 }
56 56
57 @Override 57 @Override
......
...@@ -50,7 +50,7 @@ public class LogicalTimestamp implements Timestamp { ...@@ -50,7 +50,7 @@ public class LogicalTimestamp implements Timestamp {
50 50
51 @Override 51 @Override
52 public int hashCode() { 52 public int hashCode() {
53 - return Objects.hash(value); 53 + return Long.hashCode(value);
54 } 54 }
55 55
56 @Override 56 @Override
......
...@@ -56,7 +56,7 @@ public class PartitionId { ...@@ -56,7 +56,7 @@ public class PartitionId {
56 56
57 @Override 57 @Override
58 public int hashCode() { 58 public int hashCode() {
59 - return Objects.hash(id); 59 + return id;
60 } 60 }
61 61
62 @Override 62 @Override
......
...@@ -39,7 +39,7 @@ public class DomainEdge extends AbstractEdge<DomainVertex> { ...@@ -39,7 +39,7 @@ public class DomainEdge extends AbstractEdge<DomainVertex> {
39 39
40 @Override 40 @Override
41 public int hashCode() { 41 public int hashCode() {
42 - return 43 * super.hashCode() + Objects.hash(connectPoint); 42 + return 43 * super.hashCode() + connectPoint.hashCode();
43 } 43 }
44 44
45 @Override 45 @Override
......
...@@ -63,7 +63,7 @@ public final class OpticalLogicId { ...@@ -63,7 +63,7 @@ public final class OpticalLogicId {
63 63
64 @Override 64 @Override
65 public int hashCode() { 65 public int hashCode() {
66 - return Objects.hash(logicId); 66 + return Objects.hashCode(logicId);
67 } 67 }
68 68
69 @Override 69 @Override
......
...@@ -53,7 +53,7 @@ public class DefaultVirtualDevice extends DefaultDevice implements VirtualDevice ...@@ -53,7 +53,7 @@ public class DefaultVirtualDevice extends DefaultDevice implements VirtualDevice
53 53
54 @Override 54 @Override
55 public int hashCode() { 55 public int hashCode() {
56 - return 31 * super.hashCode() + Objects.hash(networkId); 56 + return 31 * super.hashCode() + networkId.hashCode();
57 } 57 }
58 58
59 @Override 59 @Override
......
...@@ -59,7 +59,7 @@ public final class TenantId { ...@@ -59,7 +59,7 @@ public final class TenantId {
59 59
60 @Override 60 @Override
61 public int hashCode() { 61 public int hashCode() {
62 - return Objects.hash(id); 62 + return id.hashCode();
63 } 63 }
64 64
65 @Override 65 @Override
......
...@@ -49,7 +49,7 @@ public final class OvsdbBridgeName { ...@@ -49,7 +49,7 @@ public final class OvsdbBridgeName {
49 49
50 @Override 50 @Override
51 public int hashCode() { 51 public int hashCode() {
52 - return Objects.hash(value); 52 + return value.hashCode();
53 } 53 }
54 54
55 @Override 55 @Override
......
...@@ -47,7 +47,7 @@ public final class OvsdbDatapathId { ...@@ -47,7 +47,7 @@ public final class OvsdbDatapathId {
47 47
48 @Override 48 @Override
49 public int hashCode() { 49 public int hashCode() {
50 - return Objects.hash(value); 50 + return value.hashCode();
51 } 51 }
52 52
53 @Override 53 @Override
......
...@@ -47,7 +47,7 @@ public class OvsdbIfaceId { ...@@ -47,7 +47,7 @@ public class OvsdbIfaceId {
47 47
48 @Override 48 @Override
49 public int hashCode() { 49 public int hashCode() {
50 - return Objects.hash(value); 50 + return value.hashCode();
51 } 51 }
52 52
53 @Override 53 @Override
......
...@@ -44,7 +44,7 @@ public final class OvsdbNodeId { ...@@ -44,7 +44,7 @@ public final class OvsdbNodeId {
44 44
45 @Override 45 @Override
46 public int hashCode() { 46 public int hashCode() {
47 - return Objects.hash(nodeId); 47 + return nodeId.hashCode();
48 } 48 }
49 49
50 @Override 50 @Override
......
...@@ -49,7 +49,7 @@ public final class OvsdbPortName { ...@@ -49,7 +49,7 @@ public final class OvsdbPortName {
49 49
50 @Override 50 @Override
51 public int hashCode() { 51 public int hashCode() {
52 - return Objects.hash(value); 52 + return value.hashCode();
53 } 53 }
54 54
55 @Override 55 @Override
......
...@@ -47,7 +47,7 @@ public final class OvsdbPortNumber { ...@@ -47,7 +47,7 @@ public final class OvsdbPortNumber {
47 47
48 @Override 48 @Override
49 public int hashCode() { 49 public int hashCode() {
50 - return Objects.hash(value); 50 + return Objects.hashCode(value);
51 } 51 }
52 52
53 @Override 53 @Override
......
...@@ -49,7 +49,7 @@ public class OvsdbPortType { ...@@ -49,7 +49,7 @@ public class OvsdbPortType {
49 49
50 @Override 50 @Override
51 public int hashCode() { 51 public int hashCode() {
52 - return Objects.hash(value); 52 + return value.hashCode();
53 } 53 }
54 54
55 @Override 55 @Override
......
...@@ -48,7 +48,7 @@ public final class OvsdbTunnelName { ...@@ -48,7 +48,7 @@ public final class OvsdbTunnelName {
48 48
49 @Override 49 @Override
50 public int hashCode() { 50 public int hashCode() {
51 - return Objects.hash(value); 51 + return value.hashCode();
52 } 52 }
53 53
54 @Override 54 @Override
......
...@@ -85,7 +85,7 @@ public final class TableUpdate { ...@@ -85,7 +85,7 @@ public final class TableUpdate {
85 85
86 @Override 86 @Override
87 public int hashCode() { 87 public int hashCode() {
88 - return Objects.hash(rows); 88 + return rows.hashCode();
89 } 89 }
90 90
91 @Override 91 @Override
......
...@@ -67,7 +67,7 @@ public final class TableUpdates { ...@@ -67,7 +67,7 @@ public final class TableUpdates {
67 67
68 @Override 68 @Override
69 public int hashCode() { 69 public int hashCode() {
70 - return Objects.hash(result); 70 + return result.hashCode();
71 } 71 }
72 72
73 @Override 73 @Override
......
...@@ -61,7 +61,7 @@ public final class OvsdbMap { ...@@ -61,7 +61,7 @@ public final class OvsdbMap {
61 61
62 @Override 62 @Override
63 public int hashCode() { 63 public int hashCode() {
64 - return Objects.hash(map); 64 + return map.hashCode();
65 } 65 }
66 66
67 @Override 67 @Override
......
...@@ -63,7 +63,7 @@ public final class OvsdbSet { ...@@ -63,7 +63,7 @@ public final class OvsdbSet {
63 63
64 @Override 64 @Override
65 public int hashCode() { 65 public int hashCode() {
66 - return Objects.hash(set); 66 + return set.hashCode();
67 } 67 }
68 68
69 @Override 69 @Override
......
...@@ -62,7 +62,7 @@ public final class UUID { ...@@ -62,7 +62,7 @@ public final class UUID {
62 62
63 @Override 63 @Override
64 public int hashCode() { 64 public int hashCode() {
65 - return Objects.hash(value); 65 + return value.hashCode();
66 } 66 }
67 67
68 @Override 68 @Override
......
...@@ -210,7 +210,7 @@ public abstract class AbstractOvsdbTableService implements OvsdbTableService { ...@@ -210,7 +210,7 @@ public abstract class AbstractOvsdbTableService implements OvsdbTableService {
210 return null; 210 return null;
211 } 211 }
212 ColumnDescription columnDesc = new ColumnDescription("_uuid", "getTableUuidColumn"); 212 ColumnDescription columnDesc = new ColumnDescription("_uuid", "getTableUuidColumn");
213 - return (Column) getColumnHandler(columnDesc); 213 + return getColumnHandler(columnDesc);
214 } 214 }
215 215
216 @Override 216 @Override
...@@ -228,7 +228,7 @@ public abstract class AbstractOvsdbTableService implements OvsdbTableService { ...@@ -228,7 +228,7 @@ public abstract class AbstractOvsdbTableService implements OvsdbTableService {
228 return null; 228 return null;
229 } 229 }
230 ColumnDescription columnDesc = new ColumnDescription("_version", "getTableVersionColumn"); 230 ColumnDescription columnDesc = new ColumnDescription("_version", "getTableVersionColumn");
231 - return (Column) getColumnHandler(columnDesc); 231 + return getColumnHandler(columnDesc);
232 } 232 }
233 233
234 /** 234 /**
...@@ -260,7 +260,7 @@ public abstract class AbstractOvsdbTableService implements OvsdbTableService { ...@@ -260,7 +260,7 @@ public abstract class AbstractOvsdbTableService implements OvsdbTableService {
260 260
261 @Override 261 @Override
262 public int hashCode() { 262 public int hashCode() {
263 - return Objects.hash(row); 263 + return row.hashCode();
264 } 264 }
265 265
266 @Override 266 @Override
...@@ -277,7 +277,7 @@ public abstract class AbstractOvsdbTableService implements OvsdbTableService { ...@@ -277,7 +277,7 @@ public abstract class AbstractOvsdbTableService implements OvsdbTableService {
277 277
278 @Override 278 @Override
279 public String toString() { 279 public String toString() {
280 - TableSchema schema = (TableSchema) getTableSchema(); 280 + TableSchema schema = getTableSchema();
281 String tableName = schema.name(); 281 String tableName = schema.name();
282 return toStringHelper(this).add("tableName", tableName).add("row", row).toString(); 282 return toStringHelper(this).add("tableName", tableName).add("row", row).toString();
283 } 283 }
......
...@@ -110,7 +110,7 @@ public class DependencyCycle { ...@@ -110,7 +110,7 @@ public class DependencyCycle {
110 110
111 @Override 111 @Override
112 public int hashCode() { 112 public int hashCode() {
113 - return Objects.hash(cycle); 113 + return cycle.hashCode();
114 } 114 }
115 115
116 @Override 116 @Override
......
...@@ -30,8 +30,8 @@ import static com.google.common.base.MoreObjects.toStringHelper; ...@@ -30,8 +30,8 @@ import static com.google.common.base.MoreObjects.toStringHelper;
30 */ 30 */
31 public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Path<V, E> { 31 public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Path<V, E> {
32 32
33 - private Path<V, E> primary, secondary; 33 + private final Path<V, E> primary, secondary;
34 - boolean primaryActive = true; 34 + private boolean primaryActive = true;
35 35
36 /** 36 /**
37 * Creates a disjoint path pair from two paths. 37 * Creates a disjoint path pair from two paths.
...@@ -88,7 +88,7 @@ public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Pa ...@@ -88,7 +88,7 @@ public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Pa
88 * @return boolean representing whether it has backup 88 * @return boolean representing whether it has backup
89 */ 89 */
90 public boolean hasBackup() { 90 public boolean hasBackup() {
91 - return secondary != null && secondary.edges() != null; 91 + return secondary != null;
92 } 92 }
93 93
94 @Override 94 @Override
...@@ -103,7 +103,9 @@ public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Pa ...@@ -103,7 +103,9 @@ public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Pa
103 103
104 @Override 104 @Override
105 public int hashCode() { 105 public int hashCode() {
106 - return hasBackup() ? Objects.hash(primary) + Objects.hash(secondary) : 106 + // Note: DisjointPathPair with primary and secondary swapped
107 + // must result in same hashCode
108 + return hasBackup() ? primary.hashCode() + secondary.hashCode() :
107 Objects.hash(primary); 109 Objects.hash(primary);
108 } 110 }
109 111
......
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -
18 -package org.onlab.graph;
19 -
20 -import java.util.List;
21 -import java.util.Objects;
22 -import java.util.Set;
23 -
24 -import static com.google.common.collect.ImmutableSet.of;
25 -import static com.google.common.base.MoreObjects.toStringHelper;
26 -
27 -
28 -public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Path<V, E> {
29 - public Path<V, E> path1, path2;
30 - boolean usingPath1 = true;
31 -
32 -<<<<<<< HEAD
33 - /**
34 - * Creates a Disjoint Path Pair from two paths.
35 - *
36 - * @param p1 first path
37 - * @param p2 second path
38 - */
39 -=======
40 ->>>>>>> Disjoint Path Pairs (Suurballe) utils
41 - public DisjointPathPair(Path<V, E> p1, Path<V, E> p2) {
42 - path1 = p1;
43 - path2 = p2;
44 - }
45 -<<<<<<< HEAD
46 -
47 - @Override
48 -=======
49 ->>>>>>> Disjoint Path Pairs (Suurballe) utils
50 - public V src() {
51 - return path1.src();
52 - }
53 -
54 -<<<<<<< HEAD
55 - @Override
56 - public V dst() {
57 - return path1.dst();
58 - }
59 -
60 - @Override
61 -=======
62 - public V dst() {
63 - return path1.dst();
64 - }
65 ->>>>>>> Disjoint Path Pairs (Suurballe) utils
66 - public double cost() {
67 - if (!hasBackup()) {
68 - return path1.cost();
69 - }
70 - return path1.cost() + path2.cost();
71 - }
72 -<<<<<<< HEAD
73 -
74 - @Override
75 -=======
76 ->>>>>>> Disjoint Path Pairs (Suurballe) utils
77 - public List<E> edges() {
78 - if (usingPath1 || !hasBackup()) {
79 - return path1.edges();
80 - } else {
81 - return path2.edges();
82 - }
83 - }
84 -<<<<<<< HEAD
85 -
86 - /**
87 - * Checks if this path pair contains a backup/secondary path.
88 - *
89 - * @return boolean representing whether it has backup
90 - */
91 - public boolean hasBackup() {
92 - return path2 != null && path2.edges() != null;
93 - }
94 -
95 - /**
96 - * Switches this disjoint path pair to using its backup path, instead of
97 - * using its primary.
98 - */
99 - public void useBackup() {
100 - usingPath1 = !usingPath1;
101 - }
102 -
103 - @Override
104 -=======
105 - public boolean hasBackup() {
106 - return path2 != null && path2.edges() != null;
107 - }
108 - public void useBackup() {
109 - usingPath1 = !usingPath1;
110 - }
111 ->>>>>>> Disjoint Path Pairs (Suurballe) utils
112 - public String toString() {
113 - return toStringHelper(this)
114 - .add("src", src())
115 - .add("dst", dst())
116 - .add("cost", cost())
117 - .add("edges", edges())
118 - .toString();
119 - }
120 -<<<<<<< HEAD
121 -
122 - @Override
123 -=======
124 ->>>>>>> Disjoint Path Pairs (Suurballe) utils
125 - public int hashCode() {
126 - Set<Path<V, E>> paths;
127 - if (!hasBackup()) {
128 - paths = of(path1);
129 - } else {
130 - paths = of(path1, path2);
131 - }
132 - return Objects.hash(paths);
133 - }
134 -<<<<<<< HEAD
135 -
136 - @Override
137 -=======
138 ->>>>>>> Disjoint Path Pairs (Suurballe) utils
139 - public boolean equals(Object obj) {
140 - if (this == obj) {
141 - return true;
142 - }
143 - if (obj instanceof DisjointPathPair) {
144 - final DisjointPathPair other = (DisjointPathPair) obj;
145 - return Objects.equals(this.src(), other.src()) &&
146 - Objects.equals(this.dst(), other.dst()) &&
147 - (Objects.equals(this.path1, other.path1) &&
148 - Objects.equals(this.path2, other.path2)) ||
149 - (Objects.equals(this.path1, other.path2) &&
150 - Objects.equals(this.path2, other.path1));
151 - }
152 - return false;
153 - }
154 -<<<<<<< HEAD
155 -
156 - /**
157 - * Returns number of paths inside this path pair object.
158 - *
159 - * @return number of paths
160 - */
161 -=======
162 ->>>>>>> Disjoint Path Pairs (Suurballe) utils
163 - public int size() {
164 - if (hasBackup()) {
165 - return 2;
166 - }
167 - return 1;
168 - }
169 -}
...@@ -18,8 +18,6 @@ package org.onlab.util; ...@@ -18,8 +18,6 @@ package org.onlab.util;
18 import com.google.common.base.MoreObjects; 18 import com.google.common.base.MoreObjects;
19 import com.google.common.collect.ComparisonChain; 19 import com.google.common.collect.ComparisonChain;
20 20
21 -import java.util.Objects;
22 -
23 /** 21 /**
24 * Class representing frequency. This class is intended to be used for a value whose unit is Hz 22 * Class representing frequency. This class is intended to be used for a value whose unit is Hz
25 * and its family (KHz, MHz, etc.). 23 * and its family (KHz, MHz, etc.).
...@@ -157,7 +155,7 @@ public final class Frequency implements RichComparable<Frequency> { ...@@ -157,7 +155,7 @@ public final class Frequency implements RichComparable<Frequency> {
157 155
158 @Override 156 @Override
159 public int hashCode() { 157 public int hashCode() {
160 - return Objects.hash(frequency); 158 + return Long.hashCode(frequency);
161 } 159 }
162 160
163 @Override 161 @Override
......
1 +package org.onlab.graph;
2 +
3 +import static org.junit.Assert.*;
4 +
5 +import org.junit.Test;
6 +
7 +import com.google.common.collect.ImmutableList;
8 +import com.google.common.testing.EqualsTester;
9 +
10 +/**
11 + * Test of DisjointPathPair.
12 + */
13 +public class DisjointPathPairTest {
14 +
15 + private static final TestVertex A = new TestVertex("A");
16 + private static final TestVertex B = new TestVertex("B");
17 + private static final TestVertex C = new TestVertex("C");
18 + private static final TestVertex D = new TestVertex("D");
19 +
20 + private static final TestEdge AB = new TestEdge(A, B, 1.0);
21 + private static final TestEdge BC = new TestEdge(B, C, 1.0);
22 + private static final TestEdge AD = new TestEdge(A, D, 1.0);
23 + private static final TestEdge DC = new TestEdge(D, C, 1.0);
24 +
25 + private static final Path<TestVertex, TestEdge> ABC
26 + = new DefaultPath<>(ImmutableList.of(AB, BC), 1.0);
27 + private static final Path<TestVertex, TestEdge> ADC
28 + = new DefaultPath<>(ImmutableList.of(AD, DC), 1.0);
29 +
30 + @Test
31 + public void testSwappingPrimarySecondaryDoesntImpactHashCode() {
32 + assertEquals(new DisjointPathPair<>(ABC, ADC).hashCode(),
33 + new DisjointPathPair<>(ADC, ABC).hashCode());
34 + }
35 +
36 + @Test
37 + public void testSwappingPrimarySecondaryDoesntImpactEquality() {
38 + new EqualsTester()
39 + .addEqualityGroup(new DisjointPathPair<>(ABC, ADC),
40 + new DisjointPathPair<>(ADC, ABC));
41 + }
42 +
43 +}
...@@ -30,7 +30,7 @@ public class TestVertex implements Vertex { ...@@ -30,7 +30,7 @@ public class TestVertex implements Vertex {
30 30
31 @Override 31 @Override
32 public int hashCode() { 32 public int hashCode() {
33 - return Objects.hash(name); 33 + return name.hashCode();
34 } 34 }
35 35
36 @Override 36 @Override
......
...@@ -101,7 +101,7 @@ public class Step implements Vertex { ...@@ -101,7 +101,7 @@ public class Step implements Vertex {
101 101
102 @Override 102 @Override
103 public int hashCode() { 103 public int hashCode() {
104 - return Objects.hash(name); 104 + return name.hashCode();
105 } 105 }
106 106
107 @Override 107 @Override
......