blob: 873a53cf854ce88232b1e104bddd5df1e8dffd61 [file] [log] [blame]
Rimon Ashkenazye2410ff2015-11-10 14:11:08 +02001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Rimon Ashkenazye2410ff2015-11-10 14:11:08 +02003 *
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 */
16package org.onosproject.net;
17
18import com.google.common.base.MoreObjects;
19
20/**
21 * Implementation of ODU Tributary Slot simply designated by an index number of slot.
22 */
23public class TributarySlot {
24
25 private final long index;
26
27 /**
28 * Creates an instance representing the TributarySlot specified by the given index number.
29 *
30 * @param index index number of wavelength
31 */
32 public TributarySlot(long index) {
33 this.index = index;
34 }
35
36 public static TributarySlot of(long index) {
37 return new TributarySlot(index);
38 }
39
40 /**
41 * Returns the index number of TributarySlot.
42 *
43 * @return the index number of TributarySlot
44 */
45 public long index() {
46 return index;
47 }
48
49 @Override
50 public int hashCode() {
51 return Long.hashCode(index);
52 }
53
54 @Override
55 public boolean equals(Object obj) {
56 if (this == obj) {
57 return true;
58 }
59 if (!(obj instanceof TributarySlot)) {
60 return false;
61 }
62
63 final TributarySlot that = (TributarySlot) obj;
64 return this.index == that.index;
65 }
66
67 @Override
68 public String toString() {
69 return MoreObjects.toStringHelper(this)
70 .add("index", index)
71 .toString();
72 }
73}