blob: e79713038394f6368f5fd51ac5c23389a436c468 [file] [log] [blame]
Simon Hunt3a0598f2015-08-04 19:59:04 -07001/*
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
18package org.onosproject.ui.topo;
19
20/**
21 * Designates a descriptor for a button on the topology view panels.
22 */
23public class ButtonDescriptor {
24
25 private final String id;
26 private final String glyphId;
27 private final String tooltip;
28
29 /**
30 * Creates a button descriptor with the given identifier, glyph ID, and
31 * tooltip text. To reference a custom glyph defined in the overlay itself,
32 * prefix its ID with an asterisk, (e.g. {@code "*myGlyph"}). Alternatively,
33 * use one of the {@link TopoConstants.Glyphs predefined constant}.
34 *
35 * @param id identifier for the button
36 * @param glyphId identifier for the glyph
37 * @param tooltip tooltip text
38 */
39 public ButtonDescriptor(String id, String glyphId, String tooltip) {
40 this.id = id;
41 this.glyphId = glyphId;
42 this.tooltip = tooltip;
43 }
44
45 /**
46 * Returns the identifier for this button.
47 *
48 * @return identifier
49 */
50 public String id() {
51 return id;
52 }
53
54 /**
55 * Returns the glyph identifier for this button.
56 *
57 * @return glyph identifier
58 */
59 public String glyphId() {
60 return glyphId;
61 }
62
63 /**
64 * Returns the tooltip text for this button.
65 *
66 * @return tooltip text
67 */
68 public String tooltip() {
69 return tooltip;
70 }
71
72 @Override
73 public boolean equals(Object o) {
74 if (this == o) {
75 return true;
76 }
77 if (o == null || getClass() != o.getClass()) {
78 return false;
79 }
80
81 ButtonDescriptor that = (ButtonDescriptor) o;
82 return id.equals(that.id);
83
84 }
85
86 @Override
87 public int hashCode() {
88 return id.hashCode();
89 }
90}