blob: 2481830d14049e7340f6c6dfaade99fa3a7e86b7 [file] [log] [blame]
Mohammad Shahid4c30ea32017-08-09 18:02:10 +05301/*
2 * Copyright 2017-present Open Networking Foundation
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
17package org.onosproject.evpnopenflow.rsc;
18
19import org.onosproject.incubator.net.routing.VpnRouteTarget;
20
21import static com.google.common.base.MoreObjects.toStringHelper;
22import static com.google.common.base.Preconditions.checkNotNull;
23import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ID_CANNOT_BE_NULL;
24import static org.onosproject.evpnopenflow.rsc.EvpnConstants.RT_CANNOT_BE_NULL;
25import static org.onosproject.evpnopenflow.rsc.EvpnConstants.RT_TYPE_CANNOT_BE_NULL;
26
27/**
28 * Default implementation of VPN AF configuration.
29 */
30public class DefaultVpnAfConfig implements VpnAfConfig {
31
32 private final String exportRoutePolicy;
33 private final String importRoutePolicy;
34 private final VpnRouteTarget routeTarget;
35 private final String routeTargetType;
36
37 /**
38 * creates vpn af configuration object.
39 *
40 * @param exportRoutePolicy export route policy
41 * @param importRoutePolicy import route policy
42 * @param routeTarget route target value
43 * @param routeTargetType route target type
44 */
45 public DefaultVpnAfConfig(String exportRoutePolicy,
46 String importRoutePolicy,
47 VpnRouteTarget routeTarget,
48 String routeTargetType) {
49 this.exportRoutePolicy = checkNotNull(exportRoutePolicy,
50 ID_CANNOT_BE_NULL);
51 this.importRoutePolicy = checkNotNull(importRoutePolicy,
52 ID_CANNOT_BE_NULL);
53 this.routeTarget = checkNotNull(routeTarget, RT_CANNOT_BE_NULL);
54 this.routeTargetType = checkNotNull(routeTargetType,
55 RT_TYPE_CANNOT_BE_NULL);
56 }
57
58 @Override
59 public String exportRoutePolicy() {
60 return exportRoutePolicy;
61 }
62
63 @Override
64 public String importRoutePolicy() {
65 return importRoutePolicy;
66 }
67
68 @Override
69 public VpnRouteTarget routeTarget() {
70 return routeTarget;
71 }
72
73 @Override
74 public String routeTargetType() {
75 return routeTargetType;
76 }
77
78 @Override
79 public String toString() {
80 return toStringHelper(this)
81 .add("exportRoutePolicy", exportRoutePolicy)
82 .add("importRoutePolicy", importRoutePolicy)
83 .add("routeTarget", routeTarget)
84 .add("routeTargetType", routeTargetType)
85 .toString();
86 }
87}