Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 1 | /* |
| 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 Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | package org.onosproject.ui.topo; |
| 18 | |
| 19 | import com.google.common.base.MoreObjects; |
| 20 | |
| 21 | /** |
| 22 | * Designates the identity of a button on the topology view panels. |
| 23 | */ |
| 24 | public 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 | } |