blob: ec4e239173a2b22e9e57410b3618928b81f346a9 [file] [log] [blame]
Steven Burrows3a9a6442016-05-05 15:31:16 +01001/*
Brian O'Connor0a4e6742016-09-15 23:03:10 -07002 * Copyright 2016-present Open Networking Laboratory
Steven Burrows3a9a6442016-05-05 15:31:16 +01003 *
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;
18
chengfanfdd497c2016-11-25 22:17:58 +080019import static com.google.common.base.Preconditions.checkState;
20
Steven Burrows3a9a6442016-05-05 15:31:16 +010021/**
Simon Hunt8add9ee2016-09-20 17:05:07 -070022 * Represents a geographically-based map to be used in the user interface
23 * topology view. Instances of this class are immutable.
Steven Burrows3a9a6442016-05-05 15:31:16 +010024 */
25public class UiTopoMap {
26
27 private final String id;
Simon Hunt8add9ee2016-09-20 17:05:07 -070028 private final String desc;
Steven Burrows3a9a6442016-05-05 15:31:16 +010029 private final String filePath;
30 private final double scale;
chengfanfdd497c2016-11-25 22:17:58 +080031 private static final int MAX_LENGTH = 32;
32 private static final String DES_EXC_LIM = "Description is too long";
Steven Burrows3a9a6442016-05-05 15:31:16 +010033
34
35 /**
36 * Creates a new topology map.
37 *
38 * @param id map identifier
Simon Hunt8add9ee2016-09-20 17:05:07 -070039 * @param desc map description
40 * @param filePath map filePath
41 * @param scale map scale
Steven Burrows3a9a6442016-05-05 15:31:16 +010042 */
Simon Hunt8add9ee2016-09-20 17:05:07 -070043 public UiTopoMap(String id, String desc, String filePath, double scale) {
chengfanfdd497c2016-11-25 22:17:58 +080044 checkState(desc.length() <= MAX_LENGTH, DES_EXC_LIM);
Steven Burrows3a9a6442016-05-05 15:31:16 +010045 this.id = id;
Simon Hunt8add9ee2016-09-20 17:05:07 -070046 this.desc = desc;
Steven Burrows3a9a6442016-05-05 15:31:16 +010047 this.filePath = filePath;
48 this.scale = scale;
49 }
50
51 /**
52 * Returns the identifier for this map.
53 *
54 * @return the identifier
55 */
Simon Hunt8add9ee2016-09-20 17:05:07 -070056 public String id() {
57 return id;
Steven Burrows3a9a6442016-05-05 15:31:16 +010058 }
59
60 /**
61 * Returns the description for this map.
62 *
63 * @return the description
64 */
Simon Hunt8add9ee2016-09-20 17:05:07 -070065 public String description() {
66 return desc;
Steven Burrows3a9a6442016-05-05 15:31:16 +010067 }
68
69 /**
70 * Returns the filePath for this map.
71 *
72 * @return the filePath
73 */
Simon Hunt8add9ee2016-09-20 17:05:07 -070074 public String filePath() {
75 return filePath;
Steven Burrows3a9a6442016-05-05 15:31:16 +010076 }
77
78 /**
79 * Returns the scale for this map.
80 *
81 * @return the scale
82 */
Simon Hunt8add9ee2016-09-20 17:05:07 -070083 public double scale() {
84 return scale;
Steven Burrows3a9a6442016-05-05 15:31:16 +010085 }
Steven Burrows3a9a6442016-05-05 15:31:16 +010086}