blob: 604cf652987dc10e798b35cdda7408c34d44e18e [file] [log] [blame]
Simon Huntf679c4e2016-04-01 17:02:24 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Simon Huntf679c4e2016-04-01 17:02:24 -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
19import org.onosproject.net.region.Region;
Simon Huntd5b96732016-07-08 13:22:27 -070020import org.onosproject.net.region.RegionId;
Simon Huntf679c4e2016-04-01 17:02:24 -070021
22/**
23 * Represents a specific "subset" of the UI model of the network topology
24 * that a user might wish to view. Backed by a {@link Region}.
25 */
26public class UiTopoLayout {
27
Thomas Vachuska4d66d0a2016-04-15 15:48:13 -070028 private final UiTopoLayoutId id;
29 private final Region region;
Thomas Vachuska92b016b2016-05-20 11:37:57 -070030 private final UiTopoLayoutId parent;
Simon Huntf679c4e2016-04-01 17:02:24 -070031
Thomas Vachuska4d66d0a2016-04-15 15:48:13 -070032 /**
33 * Created a new UI topology layout.
34 *
35 * @param id layout identifier
36 * @param region backing region
Thomas Vachuska92b016b2016-05-20 11:37:57 -070037 * @param parent identifier of the parent layout
Thomas Vachuska4d66d0a2016-04-15 15:48:13 -070038 */
Thomas Vachuska92b016b2016-05-20 11:37:57 -070039 public UiTopoLayout(UiTopoLayoutId id, Region region, UiTopoLayoutId parent) {
Thomas Vachuska4d66d0a2016-04-15 15:48:13 -070040 this.id = id;
41 this.region = region;
Thomas Vachuska92b016b2016-05-20 11:37:57 -070042 this.parent = parent;
Thomas Vachuska4d66d0a2016-04-15 15:48:13 -070043 }
44
Simon Huntd5b96732016-07-08 13:22:27 -070045 @Override
46 public String toString() {
47 return "{UiTopoLayout: " + id + "}";
48 }
49
Thomas Vachuska4d66d0a2016-04-15 15:48:13 -070050 /**
51 * Returns the UI layout identifier.
52 *
53 * @return identifier of the layout
54 */
55 public UiTopoLayoutId id() {
56 return id;
57 }
58
59 /**
Simon Huntd5b96732016-07-08 13:22:27 -070060 * Returns the backing region with which this layout is associated. Note
61 * that this may be null (for the root layout).
Thomas Vachuska4d66d0a2016-04-15 15:48:13 -070062 *
63 * @return backing region
64 */
65 public Region region() {
66 return region;
67 }
68
Thomas Vachuska92b016b2016-05-20 11:37:57 -070069 /**
Simon Huntd5b96732016-07-08 13:22:27 -070070 * Returns the identifier of the backing region. Will be null if the
71 * region is null.
72 *
73 * @return backing region identifier
74 */
75 public RegionId regionId() {
76 return region == null ? null : region.id();
77 }
78
79 /**
Thomas Vachuska92b016b2016-05-20 11:37:57 -070080 * Returns the parent layout identifier.
81 *
82 * @return parent layout identifier
83 */
84 public UiTopoLayoutId parent() {
85 return parent;
86 }
87
Thomas Vachuska4d66d0a2016-04-15 15:48:13 -070088 // TODO: additional properties pertinent to the layout
Simon Huntf679c4e2016-04-01 17:02:24 -070089}