Committed by
Gerrit Code Review
ECLinkStore: LinkStore based on EventuallyConsistentMap (disabled right now)
Change-Id: Ib271ad6da90eb8b4d39db160e13c84b7bb695c9b
Showing
2 changed files
with
68 additions
and
0 deletions
This diff is collapsed. Click to expand it.
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 | +package org.onosproject.store.link.impl; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import org.onosproject.net.provider.ProviderId; | ||
21 | + | ||
22 | +import com.google.common.base.MoreObjects; | ||
23 | + | ||
24 | +/** | ||
25 | + * Encapsulation of a provider supplied key. | ||
26 | + * | ||
27 | + * @param <K> key | ||
28 | + */ | ||
29 | +public class Provided<K> { | ||
30 | + private final K key; | ||
31 | + private final ProviderId providerId; | ||
32 | + | ||
33 | + public Provided(K key, ProviderId providerId) { | ||
34 | + this.key = key; | ||
35 | + this.providerId = providerId; | ||
36 | + } | ||
37 | + | ||
38 | + public ProviderId providerId() { | ||
39 | + return providerId; | ||
40 | + } | ||
41 | + | ||
42 | + public K key() { | ||
43 | + return key; | ||
44 | + } | ||
45 | + | ||
46 | + @Override | ||
47 | + public int hashCode() { | ||
48 | + return Objects.hash(key, providerId); | ||
49 | + } | ||
50 | + | ||
51 | + @Override | ||
52 | + public boolean equals(Object other) { | ||
53 | + if (other instanceof Provided) { | ||
54 | + Provided<K> that = (Provided) other; | ||
55 | + return Objects.equals(key, that.key) && | ||
56 | + Objects.equals(providerId, that.providerId); | ||
57 | + } | ||
58 | + return false; | ||
59 | + } | ||
60 | + | ||
61 | + @Override | ||
62 | + public String toString() { | ||
63 | + return MoreObjects.toStringHelper(getClass()) | ||
64 | + .add("key", key) | ||
65 | + .add("providerId", providerId) | ||
66 | + .toString(); | ||
67 | + } | ||
68 | +} |
-
Please register or login to post a comment