blob: 385fed89429b43b83a73b56a98741b70431bd26d [file] [log] [blame]
Aihua Guo1ce2dd12016-08-12 23:37:44 -04001/*
2 * Copyright 2016 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 */
16package org.onosproject.tetopology.management.api.link;
17
18import java.util.Objects;
19import com.google.common.base.MoreObjects;
20
21/**
22 * Represents a list of backup service paths on the underlay topology that
23 * protect the underlay primary path.
24 */
25public class UnderlayBackupPath extends UnderlayAbstractPath {
26 private long index;
27
28 /**
29 * Sets the index.
30 *
31 * @param index the index to set
32 */
33 public void setIndex(long index) {
34 this.index = index;
35 }
36
37 /**
38 * Returns the index.
39 *
40 * @return path index
41 */
42 public long index() {
43 return index;
44 }
45
46 @Override
47 public int hashCode() {
48 return Objects.hash(super.hashCode(), index);
49 }
50
51 @Override
52 public boolean equals(Object obj) {
53 if (this == obj) {
54 return true;
55 }
56 if (obj instanceof UnderlayBackupPath) {
57 if (!super.equals(obj)) {
58 return false;
59 }
60 UnderlayBackupPath that = (UnderlayBackupPath) obj;
61 return this.index == that.index;
62 }
63 return false;
64 }
65
66 @Override
67 public String toString() {
68 return MoreObjects.toStringHelper(getClass())
69 .add("index", index)
70 .add("ref", ref())
71 .add("pathElements", pathElements())
72 .toString();
73 }
74}