blob: a1dcc1cb67a530c9936d556380c11a7d55a52fa0 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.intent;
weibitf32383b2014-10-22 10:17:31 -070017
Ray Milkeye076c792015-03-24 09:38:30 -070018import java.util.Collections;
19
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.core.ApplicationId;
21import org.onosproject.net.ConnectPoint;
weibitf32383b2014-10-22 10:17:31 -070022
Ray Milkeye076c792015-03-24 09:38:30 -070023import static com.google.common.base.Preconditions.checkNotNull;
Sho SHIMIZUd7d18002015-01-21 14:37:14 -080024
weibitf32383b2014-10-22 10:17:31 -070025/**
Jonathan Hartc9d76732014-11-18 10:52:20 -080026 * An optical layer intent for connectivity from one transponder port to another
27 * transponder port. No traffic selector or traffic treatment are needed.
weibitf32383b2014-10-22 10:17:31 -070028 */
Ray Milkeybd4f0112015-03-02 17:07:09 -080029public final class OpticalConnectivityIntent extends Intent {
30 private final ConnectPoint src;
31 private final ConnectPoint dst;
weibitf32383b2014-10-22 10:17:31 -070032
33 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -070034 * Creates an optical connectivity intent between the specified
35 * connection points.
weibitf32383b2014-10-22 10:17:31 -070036 *
Thomas Vachuska4b420772014-10-30 16:46:17 -070037 * @param appId application identification
Ray Milkey5b3717e2015-02-05 11:44:08 -080038 * @param key intent key
39 * @param src the source transponder port
40 * @param dst the destination transponder port
41 */
Ray Milkeye076c792015-03-24 09:38:30 -070042 protected OpticalConnectivityIntent(ApplicationId appId,
Ray Milkey5b3717e2015-02-05 11:44:08 -080043 Key key,
Ray Milkeye076c792015-03-24 09:38:30 -070044 ConnectPoint src,
45 ConnectPoint dst,
46 int priority) {
47 super(appId, key, Collections.emptyList(), priority);
48 this.src = checkNotNull(src);
49 this.dst = checkNotNull(dst);
weibitf32383b2014-10-22 10:17:31 -070050 }
51
Ray Milkeye076c792015-03-24 09:38:30 -070052 /**
53 * Returns a new optical connectivity intent builder.
54 *
55 * @return host to host intent builder
56 */
57 public static Builder builder() {
58 return new Builder();
59 }
60
61
62 /**
63 * Builder for optical connectivity intents.
64 */
65 public static class Builder extends Intent.Builder {
66 private ConnectPoint src;
67 private ConnectPoint dst;
68
69 @Override
70 public Builder appId(ApplicationId appId) {
71 return (Builder) super.appId(appId);
72 }
73
74 @Override
75 public Builder key(Key key) {
76 return (Builder) super.key(key);
77 }
78
79 @Override
80 public Builder priority(int priority) {
81 return (Builder) super.priority(priority);
82 }
83
84 /**
85 * Sets the source for the intent that will be built.
86 *
87 * @param src source to use for built intent
88 * @return this builder
89 */
90 public Builder src(ConnectPoint src) {
91 this.src = src;
92 return this;
93 }
94
95 /**
96 * Sets the destination for the intent that will be built.
97 *
98 * @param dst dest to use for built intent
99 * @return this builder
100 */
101 public Builder dst(ConnectPoint dst) {
102 this.dst = dst;
103 return this;
104 }
105
106 /**
107 * Builds an optical connectivity intent from the accumulated parameters.
108 *
109 * @return point to point intent
110 */
111 public OpticalConnectivityIntent build() {
112
113 return new OpticalConnectivityIntent(
114 appId,
115 key,
116 src,
117 dst,
118 priority
119 );
120 }
121 }
Ray Milkey5b3717e2015-02-05 11:44:08 -0800122
weibitf32383b2014-10-22 10:17:31 -0700123 /**
124 * Constructor for serializer.
125 */
126 protected OpticalConnectivityIntent() {
127 super();
128 this.src = null;
129 this.dst = null;
130 }
131
132 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700133 * Returns the source transponder port.
weibitf32383b2014-10-22 10:17:31 -0700134 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700135 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700136 */
Jonathan Hartc9d76732014-11-18 10:52:20 -0800137 public ConnectPoint getSrc() {
weibitf32383b2014-10-22 10:17:31 -0700138 return src;
139 }
140
141 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700142 * Returns the destination transponder port.
weibitf32383b2014-10-22 10:17:31 -0700143 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700144 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700145 */
146 public ConnectPoint getDst() {
147 return dst;
148 }
149}