2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.onosproject.incubator.net.tunnel;
19 import java.util.Objects;
21 import com.google.common.annotations.Beta;
22 import com.google.common.primitives.UnsignedLongs;
25 * Representation of a label Id, a logical port identifier.
28 public final class OpticalLogicId {
30 * Represents a logical Id.
32 private final long logicId;
35 * Constructor, public creation is prohibited.
37 private OpticalLogicId(long id) {
42 * Returns the LabelId representing the specified long value.
44 * @param id identifier as long value
47 public static OpticalLogicId logicId(long id) {
48 return new OpticalLogicId(id);
51 public static OpticalLogicId logicId(String string) {
52 return new OpticalLogicId(UnsignedLongs.decode(string));
55 public long toLong() {
60 public String toString() {
61 return UnsignedLongs.toString(logicId);
65 public int hashCode() {
66 return Objects.hash(logicId);
70 public boolean equals(Object obj) {
74 if (obj instanceof OpticalLogicId) {
75 final OpticalLogicId other = (OpticalLogicId) obj;
76 return this.logicId == other.logicId;