Fix checkstyle issues to enforce it
[controller.git] / opendaylight / config / config-api / src / main / java / org / opendaylight / controller / config / api / IdentityAttributeRef.java
1 /*
2  * Copyright (c) 2013, 2017 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 import java.beans.ConstructorProperties;
11 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
12
13 public final class IdentityAttributeRef {
14
15     public static final String QNAME_ATTR_NAME = "qNameOfIdentity";
16
17     private final String qualifiedNameOfIdentity;
18
19     @ConstructorProperties(QNAME_ATTR_NAME)
20     public IdentityAttributeRef(final String qualifiedNameOfIdentity) {
21         if (qualifiedNameOfIdentity == null) {
22             throw new NullPointerException("Parameter " + QNAME_ATTR_NAME + " is null");
23         }
24         this.qualifiedNameOfIdentity = qualifiedNameOfIdentity;
25     }
26
27     public String getqNameOfIdentity() {
28         return qualifiedNameOfIdentity;
29     }
30
31     public <T extends BaseIdentity> Class<? extends T> resolveIdentity(final DependencyResolver resolver,
32             final Class<T> baseIdentity) {
33         return resolver.resolveIdentity(this, baseIdentity);
34     }
35
36     public <T extends BaseIdentity> void validateIdentity(final DependencyResolver resolver,
37             final Class<T> baseIdentity, final JmxAttribute jmxAttribute) {
38         resolver.validateIdentity(this, baseIdentity, jmxAttribute);
39     }
40
41     @Override
42     public String toString() {
43         final StringBuilder sb = new StringBuilder("IdentityAttributeRef{");
44         sb.append("qNameOfIdentity='").append(qualifiedNameOfIdentity).append('\'');
45         sb.append('}');
46         return sb.toString();
47     }
48
49     @Override
50     public boolean equals(final Object object) {
51         if (this == object) {
52             return true;
53         }
54         if (!(object instanceof IdentityAttributeRef)) {
55             return false;
56         }
57
58         IdentityAttributeRef that = (IdentityAttributeRef) object;
59
60         if (!qualifiedNameOfIdentity.equals(that.qualifiedNameOfIdentity)) {
61             return false;
62         }
63
64         return true;
65     }
66
67     @Override
68     public int hashCode() {
69         return qualifiedNameOfIdentity.hashCode();
70     }
71 }