Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 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 | */ |
Brian O'Connor | 6de2e20 | 2015-05-21 14:30:41 -0700 | [diff] [blame] | 16 | package org.onosproject.incubator.net.resource.label; |
| 17 | |
Brian O'Connor | 893b922 | 2015-06-25 15:07:04 -0400 | [diff] [blame] | 18 | import com.google.common.annotations.Beta; |
Brian O'Connor | 6de2e20 | 2015-05-21 14:30:41 -0700 | [diff] [blame] | 19 | import org.onosproject.net.resource.ResourceId; |
jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame] | 20 | |
| 21 | import java.util.Objects; |
| 22 | |
| 23 | /** |
| 24 | * Representation of a label. |
| 25 | */ |
Brian O'Connor | 893b922 | 2015-06-25 15:07:04 -0400 | [diff] [blame] | 26 | @Beta |
jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame] | 27 | public final class LabelResourceId implements ResourceId { |
| 28 | |
| 29 | private long labelId; |
| 30 | |
| 31 | public static LabelResourceId labelResourceId(long labelResourceId) { |
| 32 | return new LabelResourceId(labelResourceId); |
| 33 | } |
| 34 | |
| 35 | // Public construction is prohibited |
| 36 | private LabelResourceId(long labelId) { |
| 37 | this.labelId = labelId; |
| 38 | } |
| 39 | |
| 40 | public long labelId() { |
| 41 | return labelId; |
| 42 | } |
| 43 | |
| 44 | @Override |
| 45 | public int hashCode() { |
| 46 | return Objects.hashCode(labelId); |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public boolean equals(Object obj) { |
| 51 | if (obj instanceof LabelResourceId) { |
| 52 | LabelResourceId that = (LabelResourceId) obj; |
| 53 | return Objects.equals(this.labelId, that.labelId); |
| 54 | } |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public String toString() { |
| 60 | return String.valueOf(this.labelId); |
| 61 | } |
| 62 | |
| 63 | } |