blob: 73f7988dc64f6763b1880fab07702773ec2dce6c [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
Simon Hunt9bb8fb92017-05-26 16:49:05 -070019import static com.google.common.base.MoreObjects.toStringHelper;
chengfanfdd497c2016-11-25 22:17:58 +080020import static com.google.common.base.Preconditions.checkState;
21
Steven Burrows3a9a6442016-05-05 15:31:16 +010022/**
Simon Hunt8add9ee2016-09-20 17:05:07 -070023 * Represents a geographically-based map to be used in the user interface
24 * topology view. Instances of this class are immutable.
Steven Burrows3a9a6442016-05-05 15:31:16 +010025 */
26public class UiTopoMap {
27
28 private final String id;
Simon Hunt8add9ee2016-09-20 17:05:07 -070029 private final String desc;
Steven Burrows3a9a6442016-05-05 15:31:16 +010030 private final String filePath;
31 private final double scale;
chengfanfdd497c2016-11-25 22:17:58 +080032 private static final int MAX_LENGTH = 32;
33 private static final String DES_EXC_LIM = "Description is too long";
Steven Burrows3a9a6442016-05-05 15:31:16 +010034
35
36 /**
37 * Creates a new topology map.
38 *
Simon Hunt9bb8fb92017-05-26 16:49:05 -070039 * @param id map identifier
40 * @param desc map description
Simon Hunt8add9ee2016-09-20 17:05:07 -070041 * @param filePath map filePath
Simon Hunt9bb8fb92017-05-26 16:49:05 -070042 * @param scale map scale
Steven Burrows3a9a6442016-05-05 15:31:16 +010043 */
Simon Hunt8add9ee2016-09-20 17:05:07 -070044 public UiTopoMap(String id, String desc, String filePath, double scale) {
chengfanfdd497c2016-11-25 22:17:58 +080045 checkState(desc.length() <= MAX_LENGTH, DES_EXC_LIM);
Steven Burrows3a9a6442016-05-05 15:31:16 +010046 this.id = id;
Simon Hunt8add9ee2016-09-20 17:05:07 -070047 this.desc = desc;
Steven Burrows3a9a6442016-05-05 15:31:16 +010048 this.filePath = filePath;
49 this.scale = scale;
50 }
51
52 /**
53 * Returns the identifier for this map.
54 *
55 * @return the identifier
56 */
Simon Hunt8add9ee2016-09-20 17:05:07 -070057 public String id() {
58 return id;
Steven Burrows3a9a6442016-05-05 15:31:16 +010059 }
60
61 /**
62 * Returns the description for this map.
63 *
64 * @return the description
65 */
Simon Hunt8add9ee2016-09-20 17:05:07 -070066 public String description() {
67 return desc;
Steven Burrows3a9a6442016-05-05 15:31:16 +010068 }
69
70 /**
71 * Returns the filePath for this map.
72 *
73 * @return the filePath
74 */
Simon Hunt8add9ee2016-09-20 17:05:07 -070075 public String filePath() {
76 return filePath;
Steven Burrows3a9a6442016-05-05 15:31:16 +010077 }
78
79 /**
80 * Returns the scale for this map.
81 *
82 * @return the scale
83 */
Simon Hunt8add9ee2016-09-20 17:05:07 -070084 public double scale() {
85 return scale;
Steven Burrows3a9a6442016-05-05 15:31:16 +010086 }
Simon Hunt9bb8fb92017-05-26 16:49:05 -070087
88 @Override
89 public String toString() {
90 return toStringHelper(this)
91 .add("id", id)
92 .add("desc", desc)
93 .toString();
94 }
Steven Burrows3a9a6442016-05-05 15:31:16 +010095}