blob: 745011417a71f751f607efebd7ab51eb893a4c44 [file] [log] [blame]
Brian O'Connorb7baf712015-07-28 23:27:03 -07001/*
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.incubator.net.domain;
17
18import com.google.common.annotations.Beta;
19import org.onosproject.net.ConnectPoint;
20import org.onosproject.net.DeviceId;
21
22import java.util.Objects;
23import java.util.Set;
24
25/**
26 * Representation of an intent domain which includes the set of internal devices,
27 * the set of edge ports, and the implementation of the domain provider.
28 */
29@Beta
30public class IntentDomain {
31
32 private final IntentDomainId id;
33 private String name;
34
35 private Set<DeviceId> internalDevices;
36 private Set<ConnectPoint> edgePorts;
37
38 private IntentDomainProvider provider;
39
40 IntentDomain(IntentDomainId id, String name,
41 Set<DeviceId> internalDevices,
42 Set<ConnectPoint> edgePorts) {
43 this.id = id;
44 this.name = name;
45 this.internalDevices = internalDevices;
46 this.edgePorts = edgePorts;
47 }
48
49 /**
50 * Returns the id for the intent domain.
51 *
52 * @return intent domain id
53 */
54 public IntentDomainId id() {
55 return id;
56 }
57
58 /**
59 * Returns the friendly name for the intent domain.
60 *
61 * @return intent domain name
62 */
63 public String name() {
64 return name;
65 }
66
67 /**
68 * Returns the set of internal devices for the intent domain (devices under
69 * exclusive control of the intent domain).
70 *
71 * @return set of internal devices
72 */
73 public Set<DeviceId> internalDevices() {
74 return internalDevices;
75 }
76
77 /**
78 * Returns the set of edge ports for the intent domain.
79 *
80 * @return set of edge ports
81 */
82 public Set<ConnectPoint> edgePorts() {
83 return edgePorts;
84 }
85
86 /**
87 * Returns the provider for the intent domain.
88 *
89 * @return intent domain provider
90 */
91 IntentDomainProvider provider() {
92 return provider;
93 }
94
95 /**
96 * Returns the status of the intent domain. An intent domain is active if it
97 * has an intent domain provider bound, and it is inactive if one is not bound.
98 *
99 * @return true if active; false otherwise
100 */
101 public boolean isActive() {
102 return provider != null;
103 }
104
105 /**
106 * Sets the provider for the intent domain if one is not already set.
107 *
108 * @param provider new intent domain provider
109 */
110 public void setProvider(IntentDomainProvider provider) {
111 // TODO consider checkState depending on caller
112 if (this.provider == null) {
113 this.provider = provider;
114 }
115 }
116
117 /**
118 * Unsets the provider for the intent domain if the given provider matches
119 * the existing provider.
120 *
121 * @param provider provider to unset
122 */
123 public void unsetProvider(IntentDomainProvider provider) {
124 // TODO consider checkState depending on caller
125 if (Objects.equals(this.provider, provider)) {
126 this.provider = null;
127 }
128 }
129
130 //TODO add remaining setters (we will probably want to link this to the network config)
131}