blob: 9f1c40ad7cdd11f308909f095f22e3c7b5920f6a [file] [log] [blame]
Satish Kf6d87cb2015-11-30 19:59:22 +05301/*
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 */
16package org.onosproject.iptopology.api;
17
18import static com.google.common.base.MoreObjects.toStringHelper;
19
20import java.util.Objects;
21
22import org.onlab.packet.IpAddress;
23
24/**
25 * This class provides implementation of prefix traffic engineering data.
26 */
27public class PrefixTed {
28 private final IgpFlags igpFlags;
29 private final RouteTag routeTag;
30 private final ExtendedRouteTag extendedRouteTag;
31 private final Metric metric;
32 private final IpAddress fwdingAddress;
33
34 /**
35 * Constructor to initialize its parameters.
36 *
37 * @param igpFlags igp flags
38 * @param routeTag ospf route tag
39 * @param extendedRouteTag isis route tag
40 * @param metric prefix metric
41 * @param fwdingAddress forwarding address
42 */
43 /**
44 * Constructor to initialize its parameters.
45 *
46 * @param igpFlags IS-IS and OSPF flags assigned to the prefix
47 * @param routeTag IGP (ISIS or OSPF) tags of the prefix
48 * @param extendedRouteTag extended ISIS route tags of the prefix
49 * @param metric metric of the prefix
50 * @param fwdingAddress OSPF forwarding address
51 */
52 public PrefixTed(IgpFlags igpFlags, RouteTag routeTag, ExtendedRouteTag extendedRouteTag,
53 Metric metric, IpAddress fwdingAddress) {
54 this.igpFlags = igpFlags;
55 this.routeTag = routeTag;
56 this.extendedRouteTag = extendedRouteTag;
57 this.metric = metric;
58 this.fwdingAddress = fwdingAddress;
59 }
60
61 /**
62 * Provides IS-IS and OSPF flags assigned to the prefix.
63 *
64 * @return IGP flags
65 */
66 public IgpFlags igpFlags() {
67 return igpFlags;
68 }
69
70 /**
71 * Provides IGP (ISIS or OSPF) tags of the prefix.
72 *
73 * @return IGP route tag.
74 */
75 public RouteTag routeTag() {
76 return routeTag;
77 }
78
79 /**
80 * Provides extended ISIS route tags of the prefix.
81 *
82 * @return extended IS-IS route tag
83 */
84 public ExtendedRouteTag extendedRouteTag() {
85 return extendedRouteTag;
86 }
87
88 /**
89 * Provides metric of the prefix.
90 *
91 * @return prefix metric
92 */
93 public Metric metric() {
94 return metric;
95 }
96
97 /**
98 * Provides OSPF forwarding address.
99 *
100 * @return forwarding address
101 */
102 public IpAddress fwdingAddress() {
103 return fwdingAddress;
104 }
105
106
107 @Override
108 public int hashCode() {
109 return Objects.hash(igpFlags, routeTag, extendedRouteTag, metric, fwdingAddress);
110 }
111
112 @Override
113 public boolean equals(Object obj) {
114 if (this == obj) {
115 return true;
116 }
117
118 if (obj instanceof PrefixTed) {
119 PrefixTed other = (PrefixTed) obj;
120 return Objects.equals(igpFlags, other.igpFlags) && Objects.equals(extendedRouteTag, other.extendedRouteTag)
121 && Objects.equals(routeTag, other.routeTag) && Objects.equals(metric, other.metric)
122 && Objects.equals(fwdingAddress, other.fwdingAddress);
123 }
124 return false;
125 }
126
127 @Override
128 public String toString() {
129 return toStringHelper(this)
130 .omitNullValues()
131 .add("igpFlags", igpFlags)
132 .add("extendedRouteTag", extendedRouteTag)
133 .add("routeTag", routeTag)
134 .add("metric", metric)
135 .add("fwdingAddress", fwdingAddress)
136 .toString();
137 }
138}