23d8691f54674f12cc01f51b38e45ef1e8a17b62
[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 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 qNameOfIdentity;
18
19     @ConstructorProperties(QNAME_ATTR_NAME)
20     public IdentityAttributeRef(final String qNameOfIdentity) {
21         if (qNameOfIdentity == null) {
22             throw new NullPointerException("Parameter " + QNAME_ATTR_NAME + " is null");
23         }
24         this.qNameOfIdentity = qNameOfIdentity;
25     }
26
27     public String getqNameOfIdentity() {
28         return qNameOfIdentity;
29     }
30
31     public <T extends BaseIdentity> Class<? extends T> resolveIdentity(final DependencyResolver resolver, final Class<T> baseIdentity) {
32         return resolver.resolveIdentity(this, baseIdentity);
33     }
34
35     public <T extends BaseIdentity> void validateIdentity(final DependencyResolver resolver, final Class<T> baseIdentity, final JmxAttribute jmxAttribute) {
36         resolver.validateIdentity(this, baseIdentity, jmxAttribute);
37     }
38
39     @Override
40     public String toString() {
41         final StringBuilder sb = new StringBuilder("IdentityAttributeRef{");
42         sb.append("qNameOfIdentity='").append(qNameOfIdentity).append('\'');
43         sb.append('}');
44         return sb.toString();
45     }
46
47     @Override
48     public boolean equals(final Object o) {
49         if (this == o) {
50             return true;
51         }
52         if (!(o instanceof IdentityAttributeRef)) {
53             return false;
54         }
55
56         IdentityAttributeRef that = (IdentityAttributeRef) o;
57
58         if (!qNameOfIdentity.equals(that.qNameOfIdentity)) {
59             return false;
60         }
61
62         return true;
63     }
64
65     @Override
66     public int hashCode() {
67         return qNameOfIdentity.hashCode();
68     }
69
70 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.