blob: dc7bd67cd51a08f969b6c9883e6bed6e5b3b602b [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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
Ray Milkey22083ae2015-03-25 13:02:07 -070041 * @param priority priority to use for flows from this intent
Ray Milkey5b3717e2015-02-05 11:44:08 -080042 */
Ray Milkeye076c792015-03-24 09:38:30 -070043 protected OpticalConnectivityIntent(ApplicationId appId,
Ray Milkey5b3717e2015-02-05 11:44:08 -080044 Key key,
Ray Milkeye076c792015-03-24 09:38:30 -070045 ConnectPoint src,
46 ConnectPoint dst,
47 int priority) {
48 super(appId, key, Collections.emptyList(), priority);
49 this.src = checkNotNull(src);
50 this.dst = checkNotNull(dst);
weibitf32383b2014-10-22 10:17:31 -070051 }
52
Ray Milkeye076c792015-03-24 09:38:30 -070053 /**
54 * Returns a new optical connectivity intent builder.
55 *
56 * @return host to host intent builder
57 */
58 public static Builder builder() {
59 return new Builder();
60 }
61
62
63 /**
64 * Builder for optical connectivity intents.
65 */
66 public static class Builder extends Intent.Builder {
67 private ConnectPoint src;
68 private ConnectPoint dst;
69
70 @Override
71 public Builder appId(ApplicationId appId) {
72 return (Builder) super.appId(appId);
73 }
74
75 @Override
76 public Builder key(Key key) {
77 return (Builder) super.key(key);
78 }
79
80 @Override
81 public Builder priority(int priority) {
82 return (Builder) super.priority(priority);
83 }
84
85 /**
86 * Sets the source for the intent that will be built.
87 *
88 * @param src source to use for built intent
89 * @return this builder
90 */
91 public Builder src(ConnectPoint src) {
92 this.src = src;
93 return this;
94 }
95
96 /**
97 * Sets the destination for the intent that will be built.
98 *
99 * @param dst dest to use for built intent
100 * @return this builder
101 */
102 public Builder dst(ConnectPoint dst) {
103 this.dst = dst;
104 return this;
105 }
106
107 /**
108 * Builds an optical connectivity intent from the accumulated parameters.
109 *
110 * @return point to point intent
111 */
112 public OpticalConnectivityIntent build() {
113
114 return new OpticalConnectivityIntent(
115 appId,
116 key,
117 src,
118 dst,
119 priority
120 );
121 }
122 }
Ray Milkey5b3717e2015-02-05 11:44:08 -0800123
weibitf32383b2014-10-22 10:17:31 -0700124 /**
125 * Constructor for serializer.
126 */
127 protected OpticalConnectivityIntent() {
128 super();
129 this.src = null;
130 this.dst = null;
131 }
132
133 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700134 * Returns the source transponder port.
weibitf32383b2014-10-22 10:17:31 -0700135 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700136 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700137 */
Jonathan Hartc9d76732014-11-18 10:52:20 -0800138 public ConnectPoint getSrc() {
weibitf32383b2014-10-22 10:17:31 -0700139 return src;
140 }
141
142 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700143 * Returns the destination transponder port.
weibitf32383b2014-10-22 10:17:31 -0700144 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700145 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700146 */
147 public ConnectPoint getDst() {
148 return dst;
149 }
150}