blob: a2377baf4c5d51eab1126854eb27df57e9d558f4 [file] [log] [blame]
Madan Jampanibad538c2015-08-19 17:35:27 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Madan Jampanibad538c2015-08-19 17:35:27 -07003 *
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 */
16package org.onosproject.store.link.impl;
17
18import java.util.Objects;
19
20import org.onosproject.net.provider.ProviderId;
21
22import com.google.common.base.MoreObjects;
23
24/**
25 * Encapsulation of a provider supplied key.
26 *
27 * @param <K> key
28 */
29public 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}