blob: e0636d77417fa0411ca0f95e0cce0b6d641a34c3 [file] [log] [blame]
Kalyankumar Asangi27728f22016-02-17 15:46:28 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Kalyankumar Asangi27728f22016-02-17 15:46:28 +05303 *
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.ospf.controller.area;
17
18import com.google.common.base.MoreObjects;
19import com.google.common.base.Objects;
20import org.onlab.packet.Ip4Address;
21import org.onosproject.ospf.controller.OspfAreaAddressRange;
22
23/**
24 * Representation of an area address ranges.
25 * Address ranges are used in order to aggregate routing information at area boundaries.
26 * Each address range is specified by an [address,mask] pair and a status indication of
27 * either advertise or do not advertise
28 */
29public class OspfAreaAddressRangeImpl implements OspfAreaAddressRange {
30
31 public Ip4Address ipAddress;
32 public String mask;
33 public boolean advertise;
34
35 /**
36 * Gets the IP address.
37 *
38 * @return IP address
39 */
40 public Ip4Address ipAddress() {
41 return ipAddress;
42 }
43
44 /**
45 * Sets the IP address.
46 *
47 * @param ipAddress IP address
48 */
49 public void setIpAddress(Ip4Address ipAddress) {
50 this.ipAddress = ipAddress;
51 }
52
53 /**
54 * Gets the network mask.
55 *
56 * @return network mask
57 */
58 public String mask() {
59 return mask;
60 }
61
62 /**
63 * Sets the network mask.
64 *
65 * @param mask network mask value
66 */
67 public void setMask(String mask) {
68 this.mask = mask;
69 }
70
71 /**
72 * Gets the advertise value.
73 *
74 * @return advertise value
75 */
76 public boolean isAdvertise() {
77 return advertise;
78 }
79
80 /**
81 * Sets the advertise value.
82 *
83 * @param advertise advertise value
84 */
85 public void setAdvertise(boolean advertise) {
86 this.advertise = advertise;
87 }
88
89 @Override
90 public boolean equals(Object other) {
91 if (!(other instanceof OspfAreaAddressRangeImpl)) {
92 return false;
93 }
94 OspfAreaAddressRangeImpl otherAreaAddressRange = (OspfAreaAddressRangeImpl) other;
95 return Objects.equal(ipAddress, otherAreaAddressRange.ipAddress) &&
96 Objects.equal(mask, otherAreaAddressRange.mask) &&
97 Objects.equal(advertise, otherAreaAddressRange.advertise);
98 }
99
100 @Override
101 public int hashCode() {
102 return Objects.hashCode(ipAddress, mask, advertise);
103 }
104
105 @Override
106 public String toString() {
107 return MoreObjects.toStringHelper(getClass())
108 .omitNullValues()
109 .add("ipAddress", ipAddress)
110 .add("mask", mask)
111 .add("advertise", advertise)
112 .toString();
113 }
114}