blob: 488c37bca328519a76f839bbaaad5554513a005b [file] [log] [blame]
Simon Hunt5f6dbf82016-03-30 08:53:33 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Simon Hunt5f6dbf82016-03-30 08:53:33 -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 */
16
17package org.onosproject.ui.model.topo;
18
Simon Hunt23fb1352016-04-11 12:15:19 -070019import org.onosproject.net.region.Region;
Simon Hunt642bc452016-05-04 19:34:45 -070020import org.onosproject.net.region.RegionId;
Simon Hunt23fb1352016-04-11 12:15:19 -070021
22import java.util.Set;
23import java.util.TreeSet;
24
Simon Hunt5f6dbf82016-03-30 08:53:33 -070025/**
26 * Represents a region.
27 */
28public class UiRegion extends UiNode {
Simon Hunt23fb1352016-04-11 12:15:19 -070029
30 private final Set<UiDevice> uiDevices = new TreeSet<>();
31 private final Set<UiHost> uiHosts = new TreeSet<>();
32 private final Set<UiLink> uiLinks = new TreeSet<>();
33
34 private Region region;
35
36
37 @Override
38 protected void destroy() {
39 uiDevices.forEach(UiDevice::destroy);
40 uiHosts.forEach(UiHost::destroy);
41 uiLinks.forEach(UiLink::destroy);
42
43 uiDevices.clear();
44 uiHosts.clear();
45 uiLinks.clear();
46
47 region = null;
48 }
49
Simon Hunt642bc452016-05-04 19:34:45 -070050 /**
51 * Returns the identity of the region.
52 *
53 * @return region ID
54 */
55 public RegionId id() {
56 return region.id();
57 }
58
59 @Override
60 public String idAsString() {
61 return id().toString();
62 }
Simon Hunt5f6dbf82016-03-30 08:53:33 -070063}