blob: 9c5a6c0c262e583c2386ac7bf998df4b588c5e8c [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
Thomas Vachuska52f2cd12018-11-08 21:20:04 -08002 * Copyright 2018-present Open Networking Foundation
Thomas Vachuska58de4162015-09-10 16:15:33 -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 */
Brian O'Connor6de2e202015-05-21 14:30:41 -070016package org.onosproject.incubator.net.resource.label;
jccfff0de92015-03-28 01:40:08 -070017
18import java.util.Objects;
19
Brian O'Connor893b9222015-06-25 15:07:04 -040020import com.google.common.annotations.Beta;
jccfff0de92015-03-28 01:40:08 -070021import org.onosproject.net.Annotations;
22import org.onosproject.net.DeviceId;
23import org.onosproject.net.provider.ProviderId;
24import static com.google.common.base.MoreObjects.toStringHelper;
25
26/**
27 * the implementation of a label resource of a device.
28 */
Brian O'Connor893b9222015-06-25 15:07:04 -040029@Beta
jccfff0de92015-03-28 01:40:08 -070030public final class DefaultLabelResource implements LabelResource {
31
32 private DeviceId deviceId;
33
34 private LabelResourceId labelResourceId;
35
36 /**
37 * Initialize a label resource object.
38 * @param deviceId device identifier
39 * @param labelResourceId label resource id
40 */
41 public DefaultLabelResource(String deviceId, long labelResourceId) {
42 this.deviceId = DeviceId.deviceId(deviceId);
43 this.labelResourceId = LabelResourceId.labelResourceId(labelResourceId);
44 }
45
46 /**
47 * Initialize a label resource object.
48 * @param deviceId device identifier
49 * @param labelResourceId label resource id
50 */
51 public DefaultLabelResource(DeviceId deviceId,
52 LabelResourceId labelResourceId) {
53 this.deviceId = deviceId;
54 this.labelResourceId = labelResourceId;
55 }
56
57 @Override
58 public DeviceId deviceId() {
59 return deviceId;
60 }
61
62 @Override
63 public LabelResourceId labelResourceId() {
64 return labelResourceId;
65 }
66
67 @Override
68 public Annotations annotations() {
69 return null;
70 }
71
72 @Override
73 public ProviderId providerId() {
74 return null;
75 }
76
77 @Override
78 public int hashCode() {
79 return Objects.hash(deviceId, labelResourceId);
80 }
81
82 @Override
83 public boolean equals(Object obj) {
84 if (obj instanceof DefaultLabelResource) {
85 DefaultLabelResource that = (DefaultLabelResource) obj;
86 return Objects.equals(this.deviceId, that.deviceId)
87 && Objects.equals(this.labelResourceId,
88 that.labelResourceId);
89 }
90 return false;
91 }
92
93 @Override
94 public String toString() {
95 return toStringHelper(this).add("deviceId", deviceId)
96 .add("labelResourceId", labelResourceId).toString();
97 }
98}