Simon Hunt | 0af1ec3 | 2015-07-24 12:17:55 -0700 | [diff] [blame^] | 1 | /* |
| 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 | * |
| 16 | */ |
| 17 | |
| 18 | package org.onosproject.ui.topo; |
| 19 | |
| 20 | import java.util.ArrayList; |
| 21 | import java.util.List; |
| 22 | |
| 23 | /** |
| 24 | * Models a panel displayed on the Topology View. |
| 25 | */ |
| 26 | public class PropertyPanel { |
| 27 | |
| 28 | private String title; |
| 29 | private String typeId; |
| 30 | private List<Prop> properties = new ArrayList<>(); |
| 31 | |
| 32 | |
| 33 | public PropertyPanel(String title, String typeId) { |
| 34 | this.title = title; |
| 35 | this.typeId = typeId; |
| 36 | } |
| 37 | |
| 38 | public PropertyPanel add(Prop p) { |
| 39 | properties.add(p); |
| 40 | return this; |
| 41 | } |
| 42 | |
| 43 | public String title() { |
| 44 | return title; |
| 45 | } |
| 46 | |
| 47 | public String typeId() { |
| 48 | return typeId; |
| 49 | } |
| 50 | |
| 51 | // TODO: consider protecting this? |
| 52 | public List<Prop> properties() { |
| 53 | return properties; |
| 54 | } |
| 55 | |
| 56 | public PropertyPanel title(String title) { |
| 57 | this.title = title; |
| 58 | return this; |
| 59 | } |
| 60 | |
| 61 | // TODO: add other builder-like setters here |
| 62 | |
| 63 | |
| 64 | // ==================== |
| 65 | |
| 66 | public static class Prop { |
| 67 | public final String key; |
| 68 | public final String value; |
| 69 | |
| 70 | public Prop(String key, String value) { |
| 71 | this.key = key; |
| 72 | this.value = value; |
| 73 | } |
| 74 | |
| 75 | public String key() { |
| 76 | return key; |
| 77 | } |
| 78 | |
| 79 | public String value() { |
| 80 | return value; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | // Auxiliary properties separator |
| 85 | public static class Separator extends Prop { |
| 86 | public Separator() { |
| 87 | super("-", ""); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | } |