244f22f58efdd5b1615806a2859fd50902b79172
[controller.git] / opendaylight / config / config-api / src / main / java / org / opendaylight / controller / config / api / JmxAttribute.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.config.api;
9
10 /**
11  * Wrapper around strings to make {@link JmxAttributeValidationException} type
12  * safe.
13  */
14 public class JmxAttribute {
15     private final String attributeName;
16
17     public JmxAttribute(String attributeName) {
18         if (attributeName == null) {
19             throw new NullPointerException("Parameter 'attributeName' is null");
20         }
21         this.attributeName = attributeName;
22     }
23
24     public String getAttributeName() {
25         return attributeName;
26     }
27
28     @Override
29     public boolean equals(Object o) {
30         if (this == o) {
31             return true;
32         }
33         if (o == null || getClass() != o.getClass()) {
34             return false;
35         }
36
37         JmxAttribute that = (JmxAttribute) o;
38
39         if (attributeName != null ? !attributeName.equals(that.attributeName)
40                 : that.attributeName != null) {
41             return false;
42         }
43
44         return true;
45     }
46
47     @Override
48     public int hashCode() {
49         return attributeName != null ? attributeName.hashCode() : 0;
50     }
51
52     @Override
53     public String toString() {
54         return "JmxAttribute{'" + attributeName + "'}";
55     }
56 }