ECDeviceStore: DeviceStore built using ONOS distributed primitives: ECMap and Di…
…stributedSet (disabled right now) Change-Id: I36fdcd635f982f2b8dac291c52be4662601ef9f0
Showing
3 changed files
with
149 additions
and
0 deletions
1 | +/* | ||
2 | + * Copyright 2014-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 | +package org.onosproject.store.device.impl; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import org.onosproject.net.DeviceId; | ||
21 | +import org.onosproject.net.provider.ProviderId; | ||
22 | + | ||
23 | +import com.google.common.base.MoreObjects; | ||
24 | + | ||
25 | +/** | ||
26 | + * Key for DeviceDescriptions in ECDeviceStore. | ||
27 | + */ | ||
28 | +public class DeviceKey { | ||
29 | + private final ProviderId providerId; | ||
30 | + private final DeviceId deviceId; | ||
31 | + | ||
32 | + public DeviceKey(ProviderId providerId, DeviceId deviceId) { | ||
33 | + this.providerId = providerId; | ||
34 | + this.deviceId = deviceId; | ||
35 | + } | ||
36 | + | ||
37 | + public ProviderId providerId() { | ||
38 | + return providerId; | ||
39 | + } | ||
40 | + | ||
41 | + public DeviceId deviceId() { | ||
42 | + return deviceId; | ||
43 | + } | ||
44 | + | ||
45 | + @Override | ||
46 | + public int hashCode() { | ||
47 | + return Objects.hash(providerId, deviceId); | ||
48 | + } | ||
49 | + | ||
50 | + @Override | ||
51 | + public boolean equals(Object obj) { | ||
52 | + if (this == obj) { | ||
53 | + return true; | ||
54 | + } | ||
55 | + if (!(obj instanceof DeviceKey)) { | ||
56 | + return false; | ||
57 | + } | ||
58 | + DeviceKey that = (DeviceKey) obj; | ||
59 | + return Objects.equals(this.deviceId, that.deviceId) && | ||
60 | + Objects.equals(this.providerId, that.providerId); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public String toString() { | ||
65 | + return MoreObjects.toStringHelper(getClass()) | ||
66 | + .add("providerId", providerId) | ||
67 | + .add("deviceId", deviceId) | ||
68 | + .toString(); | ||
69 | + } | ||
70 | +} |
This diff is collapsed. Click to expand it.
1 | +/* | ||
2 | + * Copyright 2014-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 | +package org.onosproject.store.device.impl; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import org.onosproject.net.DeviceId; | ||
21 | +import org.onosproject.net.PortNumber; | ||
22 | +import org.onosproject.net.provider.ProviderId; | ||
23 | + | ||
24 | +import com.google.common.base.MoreObjects; | ||
25 | + | ||
26 | +/** | ||
27 | + * Key for PortDescriptions in ECDeviceStore. | ||
28 | + */ | ||
29 | +public class PortKey { | ||
30 | + private final ProviderId providerId; | ||
31 | + private final DeviceId deviceId; | ||
32 | + private final PortNumber portNumber; | ||
33 | + | ||
34 | + public PortKey(ProviderId providerId, DeviceId deviceId, PortNumber portNumber) { | ||
35 | + this.providerId = providerId; | ||
36 | + this.deviceId = deviceId; | ||
37 | + this.portNumber = portNumber; | ||
38 | + } | ||
39 | + | ||
40 | + public ProviderId providerId() { | ||
41 | + return providerId; | ||
42 | + } | ||
43 | + | ||
44 | + public DeviceId deviceId() { | ||
45 | + return deviceId; | ||
46 | + } | ||
47 | + | ||
48 | + public PortNumber portNumber() { | ||
49 | + return portNumber; | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public int hashCode() { | ||
54 | + return Objects.hash(providerId, deviceId, portNumber); | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public boolean equals(Object obj) { | ||
59 | + if (this == obj) { | ||
60 | + return true; | ||
61 | + } | ||
62 | + if (!(obj instanceof PortKey)) { | ||
63 | + return false; | ||
64 | + } | ||
65 | + PortKey that = (PortKey) obj; | ||
66 | + return Objects.equals(this.deviceId, that.deviceId) && | ||
67 | + Objects.equals(this.providerId, that.providerId) && | ||
68 | + Objects.equals(this.portNumber, that.portNumber); | ||
69 | + } | ||
70 | + | ||
71 | + @Override | ||
72 | + public String toString() { | ||
73 | + return MoreObjects.toStringHelper(getClass()) | ||
74 | + .add("providerId", providerId) | ||
75 | + .add("deviceId", deviceId) | ||
76 | + .add("portNumber", portNumber) | ||
77 | + .toString(); | ||
78 | + } | ||
79 | +} |
-
Please register or login to post a comment