Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016 Open Networking Foundation |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.tetopology.management.api.link; |
| 17 | |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 18 | import java.util.List; |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 19 | import java.util.Objects; |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 20 | |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 21 | import 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 | */ |
| 27 | public class UnderlayBackupPath extends UnderlayAbstractPath { |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 28 | private final long index; |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 29 | |
| 30 | /** |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 31 | * Creates a underlay backup path. |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 32 | * |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 33 | * @param index the path index |
| 34 | * @param pathElements list of backup service paths |
| 35 | * @param loose loose if true; restrict otherwise |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 36 | */ |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 37 | public UnderlayBackupPath(long index, List<PathElement> pathElements, |
| 38 | Boolean loose) { |
| 39 | super(pathElements, loose); |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 40 | this.index = index; |
| 41 | } |
| 42 | |
| 43 | /** |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 44 | * Returns the path index. |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 45 | * |
| 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 Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 75 | .add("index", index) |
| 76 | .add("pathElements", pathElements()) |
| 77 | .add("loose", loose()) |
| 78 | .toString(); |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 79 | } |
| 80 | } |