Simon Hunt | f679c4e | 2016-04-01 17:02:24 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Simon Hunt | f679c4e | 2016-04-01 17:02:24 -0700 | [diff] [blame] | 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 | */ |
| 16 | |
| 17 | package org.onosproject.ui.model.topo; |
| 18 | |
| 19 | import org.onosproject.net.region.Region; |
Simon Hunt | d5b9673 | 2016-07-08 13:22:27 -0700 | [diff] [blame] | 20 | import org.onosproject.net.region.RegionId; |
Simon Hunt | f679c4e | 2016-04-01 17:02:24 -0700 | [diff] [blame] | 21 | |
| 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 | */ |
| 26 | public class UiTopoLayout { |
| 27 | |
Thomas Vachuska | 4d66d0a | 2016-04-15 15:48:13 -0700 | [diff] [blame] | 28 | private final UiTopoLayoutId id; |
| 29 | private final Region region; |
Thomas Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 30 | private final UiTopoLayoutId parent; |
Simon Hunt | f679c4e | 2016-04-01 17:02:24 -0700 | [diff] [blame] | 31 | |
Thomas Vachuska | 4d66d0a | 2016-04-15 15:48:13 -0700 | [diff] [blame] | 32 | /** |
| 33 | * Created a new UI topology layout. |
| 34 | * |
| 35 | * @param id layout identifier |
| 36 | * @param region backing region |
Thomas Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 37 | * @param parent identifier of the parent layout |
Thomas Vachuska | 4d66d0a | 2016-04-15 15:48:13 -0700 | [diff] [blame] | 38 | */ |
Thomas Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 39 | public UiTopoLayout(UiTopoLayoutId id, Region region, UiTopoLayoutId parent) { |
Thomas Vachuska | 4d66d0a | 2016-04-15 15:48:13 -0700 | [diff] [blame] | 40 | this.id = id; |
| 41 | this.region = region; |
Thomas Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 42 | this.parent = parent; |
Thomas Vachuska | 4d66d0a | 2016-04-15 15:48:13 -0700 | [diff] [blame] | 43 | } |
| 44 | |
Simon Hunt | d5b9673 | 2016-07-08 13:22:27 -0700 | [diff] [blame] | 45 | @Override |
| 46 | public String toString() { |
| 47 | return "{UiTopoLayout: " + id + "}"; |
| 48 | } |
| 49 | |
Thomas Vachuska | 4d66d0a | 2016-04-15 15:48:13 -0700 | [diff] [blame] | 50 | /** |
| 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 Hunt | d5b9673 | 2016-07-08 13:22:27 -0700 | [diff] [blame] | 60 | * Returns the backing region with which this layout is associated. Note |
| 61 | * that this may be null (for the root layout). |
Thomas Vachuska | 4d66d0a | 2016-04-15 15:48:13 -0700 | [diff] [blame] | 62 | * |
| 63 | * @return backing region |
| 64 | */ |
| 65 | public Region region() { |
| 66 | return region; |
| 67 | } |
| 68 | |
Thomas Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 69 | /** |
Simon Hunt | d5b9673 | 2016-07-08 13:22:27 -0700 | [diff] [blame] | 70 | * 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 Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 80 | * Returns the parent layout identifier. |
| 81 | * |
| 82 | * @return parent layout identifier |
| 83 | */ |
| 84 | public UiTopoLayoutId parent() { |
| 85 | return parent; |
| 86 | } |
| 87 | |
Thomas Vachuska | 4d66d0a | 2016-04-15 15:48:13 -0700 | [diff] [blame] | 88 | // TODO: additional properties pertinent to the layout |
Simon Hunt | f679c4e | 2016-04-01 17:02:24 -0700 | [diff] [blame] | 89 | } |