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