blob: 5b1a33f16e9d38e567f9b4a054ad32ad6ea56c01 [file] [log] [blame]
Aihua Guo1ce2dd12016-08-12 23:37:44 -04001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016 Open Networking Foundation
Aihua Guo1ce2dd12016-08-12 23:37:44 -04003 *
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
Henry Yu4b4a7eb2016-11-09 20:07:53 -050018import java.util.List;
Aihua Guo1ce2dd12016-08-12 23:37:44 -040019import java.util.Objects;
Henry Yu4b4a7eb2016-11-09 20:07:53 -050020
Aihua Guo1ce2dd12016-08-12 23:37:44 -040021import com.google.common.base.MoreObjects;
22
23/**
24 * Represents a list of backup service paths on the underlay topology that
25 * protect the underlay primary path.
26 */
27public class UnderlayBackupPath extends UnderlayAbstractPath {
Henry Yu4b4a7eb2016-11-09 20:07:53 -050028 private final long index;
Aihua Guo1ce2dd12016-08-12 23:37:44 -040029
30 /**
Henry Yu4b4a7eb2016-11-09 20:07:53 -050031 * Creates a underlay backup path.
Aihua Guo1ce2dd12016-08-12 23:37:44 -040032 *
Henry Yu4b4a7eb2016-11-09 20:07:53 -050033 * @param index the path index
34 * @param pathElements list of backup service paths
35 * @param loose loose if true; restrict otherwise
Aihua Guo1ce2dd12016-08-12 23:37:44 -040036 */
Henry Yu4b4a7eb2016-11-09 20:07:53 -050037 public UnderlayBackupPath(long index, List<PathElement> pathElements,
38 Boolean loose) {
39 super(pathElements, loose);
Aihua Guo1ce2dd12016-08-12 23:37:44 -040040 this.index = index;
41 }
42
43 /**
Henry Yu4b4a7eb2016-11-09 20:07:53 -050044 * Returns the path index.
Aihua Guo1ce2dd12016-08-12 23:37:44 -040045 *
46 * @return path index
47 */
48 public long index() {
49 return index;
50 }
51
52 @Override
53 public int hashCode() {
54 return Objects.hash(super.hashCode(), index);
55 }
56
57 @Override
58 public boolean equals(Object obj) {
59 if (this == obj) {
60 return true;
61 }
62 if (obj instanceof UnderlayBackupPath) {
63 if (!super.equals(obj)) {
64 return false;
65 }
66 UnderlayBackupPath that = (UnderlayBackupPath) obj;
67 return this.index == that.index;
68 }
69 return false;
70 }
71
72 @Override
73 public String toString() {
74 return MoreObjects.toStringHelper(getClass())
Henry Yu4b4a7eb2016-11-09 20:07:53 -050075 .add("index", index)
76 .add("pathElements", pathElements())
77 .add("loose", loose())
78 .toString();
Aihua Guo1ce2dd12016-08-12 23:37:44 -040079 }
80}