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