Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 52f2cd1 | 2018-11-08 21:20:04 -0800 | [diff] [blame] | 2 | * Copyright 2018-present Open Networking Foundation |
Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 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 | */ |
Brian O'Connor | 6de2e20 | 2015-05-21 14:30:41 -0700 | [diff] [blame] | 16 | package org.onosproject.incubator.net.resource.label; |
jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame] | 17 | |
| 18 | import java.util.Objects; |
| 19 | |
Brian O'Connor | 893b922 | 2015-06-25 15:07:04 -0400 | [diff] [blame] | 20 | import com.google.common.annotations.Beta; |
jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame] | 21 | import org.onosproject.net.Annotations; |
| 22 | import org.onosproject.net.DeviceId; |
| 23 | import org.onosproject.net.provider.ProviderId; |
| 24 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 25 | |
| 26 | /** |
| 27 | * the implementation of a label resource of a device. |
| 28 | */ |
Brian O'Connor | 893b922 | 2015-06-25 15:07:04 -0400 | [diff] [blame] | 29 | @Beta |
jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame] | 30 | public 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 | } |