Satish K | f6d87cb | 2015-11-30 19:59:22 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | */ |
| 16 | package org.onosproject.iptopology.api; |
| 17 | |
| 18 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 19 | |
| 20 | import java.util.Objects; |
| 21 | |
| 22 | /** |
| 23 | * This class provides implementation IS-IS and OSPF flags assigned to the prefix. |
| 24 | */ |
| 25 | public class IgpFlags { |
| 26 | private final boolean isisUpDown; |
| 27 | private final boolean ospfNoUnicast; |
| 28 | private final boolean ospfLclAddr; |
| 29 | private final boolean ospfNssa; |
| 30 | |
| 31 | /** |
| 32 | * Constructor to initialize its parameters. |
| 33 | * |
| 34 | * @param isisUpDown IS-IS Up/Down |
| 35 | * @param ospfNoUnicast OSPF no unicast |
| 36 | * @param ospfLclAddr OSPF local address |
| 37 | * @param ospfNssa OSPF propagate NSSA |
| 38 | */ |
| 39 | public IgpFlags(boolean isisUpDown, boolean ospfNoUnicast, boolean ospfLclAddr, |
| 40 | boolean ospfNssa) { |
| 41 | this.isisUpDown = isisUpDown; |
| 42 | this.ospfNoUnicast = ospfNoUnicast; |
| 43 | this.ospfLclAddr = ospfLclAddr; |
| 44 | this.ospfNssa = ospfNssa; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Provides information whether IS-IS is Up/Down. |
| 49 | * |
| 50 | * @return IS-IS Up/Down bit enabled or not |
| 51 | */ |
| 52 | public boolean isisUpDown() { |
| 53 | return isisUpDown; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Provides information whether OSPF is unicast or not. |
| 58 | * |
| 59 | * @return OSPF no unicast Bit set or not |
| 60 | */ |
| 61 | public boolean ospfNoUnicast() { |
| 62 | return ospfNoUnicast; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Provides information on OSPF local address. |
| 67 | * |
| 68 | * @return OSPF local address Bit set or not |
| 69 | */ |
| 70 | public boolean ospfLclAddr() { |
| 71 | return ospfLclAddr; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Provides information on OSPF propagate NSSA. |
| 76 | * |
| 77 | * @return OSPF propagate NSSA Bit set or not |
| 78 | */ |
| 79 | public boolean ospfNssa() { |
| 80 | return ospfNssa; |
| 81 | } |
| 82 | |
| 83 | @Override |
| 84 | public int hashCode() { |
| 85 | return Objects.hash(isisUpDown, ospfNoUnicast, ospfLclAddr, |
| 86 | ospfNssa); |
| 87 | } |
| 88 | |
| 89 | @Override |
| 90 | public boolean equals(Object obj) { |
| 91 | if (this == obj) { |
| 92 | return true; |
| 93 | } |
| 94 | |
| 95 | if (obj instanceof IgpFlags) { |
| 96 | IgpFlags other = (IgpFlags) obj; |
| 97 | return Objects.equals(isisUpDown, other.isisUpDown) |
| 98 | && Objects.equals(ospfNoUnicast, other.ospfNoUnicast) |
| 99 | && Objects.equals(ospfLclAddr, other.ospfLclAddr) |
| 100 | && Objects.equals(ospfNssa, other.ospfNssa); |
| 101 | } |
| 102 | return false; |
| 103 | } |
| 104 | |
| 105 | @Override |
| 106 | public String toString() { |
| 107 | return toStringHelper(this) |
| 108 | .add("isisUpDown", isisUpDown) |
| 109 | .add("ospfNoUnicast", ospfNoUnicast) |
| 110 | .add("ospfLclAddr", ospfLclAddr) |
| 111 | .add("ospfNssa", ospfNssa) |
| 112 | .toString(); |
| 113 | } |
| 114 | } |