blob: ca2ecccd66f2ceb1cacbe2c344edd7be85f6a10e [file] [log] [blame]
Simon Hunt8d22c4b2015-08-06 16:24:43 -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
20import com.google.common.base.MoreObjects;
21
22/**
23 * Designates the identity of a button on the topology view panels.
24 */
25public class ButtonId {
26
27 private final String id;
28
29 /**
30 * Creates a button ID with the given identifier.
31 *
32 * @param id identifier for the button
33 */
34 public ButtonId(String id) {
35 this.id = id;
36 }
37
38 /**
39 * Returns the identifier for this button.
40 *
41 * @return identifier
42 */
43 public String id() {
44 return id;
45 }
46
47 @Override
48 public String toString() {
49 return MoreObjects.toStringHelper(getClass())
50 .add("id", id()).toString();
51 }
52
53 @Override
54 public boolean equals(Object o) {
55 if (this == o) {
56 return true;
57 }
58 if (o == null || getClass() != o.getClass()) {
59 return false;
60 }
61
62 ButtonId that = (ButtonId) o;
63 return id.equals(that.id);
64 }
65
66 @Override
67 public int hashCode() {
68 return id.hashCode();
69 }
70}