blob: 2d53ab85965723a3bb2270bf95b2bbb810f93e9c [file] [log] [blame]
Thomas Vachuska24c849c2014-10-27 09:53:05 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska24c849c2014-10-27 09:53:05 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
Thomas Vachuska24c849c2014-10-27 09:53:05 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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.
Thomas Vachuska24c849c2014-10-27 09:53:05 -070015 */
alshabib7911a052014-10-16 17:49:37 -070016package org.onlab.packet;
17
Jian Li597d7b22016-02-29 14:06:55 -080018import org.onlab.util.Identifier;
19
alshabib7911a052014-10-16 17:49:37 -070020/**
21 * The class representing a network device chassisId.
22 * This class is immutable.
23 */
Jian Li597d7b22016-02-29 14:06:55 -080024public final class ChassisId extends Identifier<Long> {
alshabib7911a052014-10-16 17:49:37 -070025
26 private static final long UNKNOWN = 0;
alshabib7911a052014-10-16 17:49:37 -070027
28 /**
29 * Default constructor.
30 */
31 public ChassisId() {
Jian Li597d7b22016-02-29 14:06:55 -080032 super(ChassisId.UNKNOWN);
alshabib7911a052014-10-16 17:49:37 -070033 }
34
35 /**
36 * Constructor from a long value.
37 *
38 * @param value the value to use.
39 */
40 public ChassisId(long value) {
Jian Li597d7b22016-02-29 14:06:55 -080041 super(value);
alshabib7911a052014-10-16 17:49:37 -070042 }
43
44 /**
45 * Constructor from a string.
46 *
47 * @param value the value to use.
48 */
49 public ChassisId(String value) {
Alan Deikman54cf9572017-03-10 19:54:55 +000050 super(Long.parseUnsignedLong(value, 16));
alshabib7911a052014-10-16 17:49:37 -070051 }
52
53 /**
54 * Get the value of the chassis id.
55 *
56 * @return the value of the chassis id.
57 */
58 public long value() {
Jian Li597d7b22016-02-29 14:06:55 -080059 return identifier;
alshabib7911a052014-10-16 17:49:37 -070060 }
61
62 /**
63 * Convert the Chassis Id value to a ':' separated hexadecimal string.
64 *
65 * @return the Chassis Id value as a ':' separated hexadecimal string.
66 */
67 @Override
68 public String toString() {
Jian Li597d7b22016-02-29 14:06:55 -080069 return Long.toHexString(identifier);
alshabib7911a052014-10-16 17:49:37 -070070 }
71
72 @Override
73 public int hashCode() {
Jian Li597d7b22016-02-29 14:06:55 -080074 return Long.hashCode(identifier);
alshabib7911a052014-10-16 17:49:37 -070075 }
76}