Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0a4e674 | 2016-09-15 23:03:10 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [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; |
| 18 | |
chengfan | fdd497c | 2016-11-25 22:17:58 +0800 | [diff] [blame] | 19 | import static com.google.common.base.Preconditions.checkState; |
| 20 | |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 21 | /** |
Simon Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 22 | * Represents a geographically-based map to be used in the user interface |
| 23 | * topology view. Instances of this class are immutable. |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 24 | */ |
| 25 | public class UiTopoMap { |
| 26 | |
| 27 | private final String id; |
Simon Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 28 | private final String desc; |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 29 | private final String filePath; |
| 30 | private final double scale; |
chengfan | fdd497c | 2016-11-25 22:17:58 +0800 | [diff] [blame] | 31 | private static final int MAX_LENGTH = 32; |
| 32 | private static final String DES_EXC_LIM = "Description is too long"; |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 33 | |
| 34 | |
| 35 | /** |
| 36 | * Creates a new topology map. |
| 37 | * |
| 38 | * @param id map identifier |
Simon Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 39 | * @param desc map description |
| 40 | * @param filePath map filePath |
| 41 | * @param scale map scale |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 42 | */ |
Simon Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 43 | public UiTopoMap(String id, String desc, String filePath, double scale) { |
chengfan | fdd497c | 2016-11-25 22:17:58 +0800 | [diff] [blame] | 44 | checkState(desc.length() <= MAX_LENGTH, DES_EXC_LIM); |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 45 | this.id = id; |
Simon Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 46 | this.desc = desc; |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 47 | this.filePath = filePath; |
| 48 | this.scale = scale; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Returns the identifier for this map. |
| 53 | * |
| 54 | * @return the identifier |
| 55 | */ |
Simon Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 56 | public String id() { |
| 57 | return id; |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Returns the description for this map. |
| 62 | * |
| 63 | * @return the description |
| 64 | */ |
Simon Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 65 | public String description() { |
| 66 | return desc; |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Returns the filePath for this map. |
| 71 | * |
| 72 | * @return the filePath |
| 73 | */ |
Simon Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 74 | public String filePath() { |
| 75 | return filePath; |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Returns the scale for this map. |
| 80 | * |
| 81 | * @return the scale |
| 82 | */ |
Simon Hunt | 8add9ee | 2016-09-20 17:05:07 -0700 | [diff] [blame] | 83 | public double scale() { |
| 84 | return scale; |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 85 | } |
Steven Burrows | 3a9a644 | 2016-05-05 15:31:16 +0100 | [diff] [blame] | 86 | } |