blob: 11268f6f617b0c369a476a415ae6d030bad2371e [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
22/**
23 * Represents Route type of the prefix in the OSPF domain.
24 */
25public class RouteType {
26 private final Type routeType;
27
28 /**
29 * Enum to provide Route type.
30 */
31 public enum Type {
32 Intra_Area(1), Inter_Area(2), External_1(3), External_2(4), NSSA_1(5), NSSA_2(6);
33 int value;
34
35 /**
36 * Constructor to assign value.
37 *
38 * @param val route type
39 */
40 Type(int val) {
41 value = val;
42 }
43
44 /**
45 * Provides route type.
46 *
47 * @return route type
48 */
49 public byte type() {
50 return (byte) value;
51 }
52 }
53
54 /**
55 * Constructor to initialize routeType.
56 *
57 * @param routeType Route type
58 */
59 public RouteType(Type routeType) {
60 this.routeType = routeType;
61 }
62
63 /**
64 * Provides Route type of the prefix.
65 *
66 * @return Route type
67 */
68 public Type routeType() {
69 return routeType;
70 }
71
72 @Override
73 public int hashCode() {
74 return Objects.hash(routeType);
75 }
76
77 @Override
78 public boolean equals(Object obj) {
79 if (this == obj) {
80 return true;
81 }
82
83 if (obj instanceof RouteType) {
84 RouteType other = (RouteType) obj;
85 return Objects.equals(routeType, other.routeType);
86 }
87 return false;
88 }
89
90 @Override
91 public String toString() {
92 return toStringHelper(this)
93 .add("routeType", routeType)
94 .toString();
95 }
96}