Simon Hunt | f59d36b | 2016-10-04 19:05:53 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016-present 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 | */ |
| 16 | |
| 17 | package org.onosproject.net.config.basics; |
| 18 | |
| 19 | import org.onosproject.net.config.Config; |
| 20 | import org.onosproject.net.region.RegionId; |
| 21 | import org.onosproject.ui.model.topo.UiTopoLayoutId; |
| 22 | |
| 23 | import static org.onosproject.net.region.RegionId.regionId; |
| 24 | |
| 25 | /** |
| 26 | * Basic configuration for UI topology layouts. |
| 27 | */ |
| 28 | public class BasicUiTopoLayoutConfig extends Config<UiTopoLayoutId> { |
| 29 | |
| 30 | private static final String REGION = "region"; |
| 31 | private static final String PARENT = "parent"; |
| 32 | |
| 33 | @Override |
| 34 | public boolean isValid() { |
| 35 | return hasOnlyFields(REGION, PARENT); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Returns the identifier of the backing region. This will be |
| 40 | * null if there is no backing region. |
| 41 | * |
| 42 | * @return backing region identity |
| 43 | */ |
| 44 | public RegionId getRegion() { |
| 45 | String r = get(REGION, null); |
| 46 | return r == null ? null : regionId(r); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Returns the identifier of the parent layout. |
| 51 | * |
| 52 | * @return layout identifier of parent |
| 53 | */ |
| 54 | public UiTopoLayoutId getParent() { |
| 55 | String p = get(PARENT, null); |
| 56 | return p == null ? UiTopoLayoutId.DEFAULT_ID : UiTopoLayoutId.layoutId(p); |
| 57 | } |
| 58 | |
| 59 | // TODO: implement setters |
| 60 | } |