Add support for identity-ref config attributes to config/netconf subsystem
[controller.git] / opendaylight / config / config-api / src / main / java / org / opendaylight / controller / config / api / IdentityAttributeRef.java
diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/IdentityAttributeRef.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/IdentityAttributeRef.java
new file mode 100644 (file)
index 0000000..7373759
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.api;
+
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+
+import java.beans.ConstructorProperties;
+
+public final class IdentityAttributeRef {
+
+    public static final String QNAME_ATTR_NAME = "qNameOfIdentity";
+
+    private final String qNameOfIdentity;
+
+    @ConstructorProperties(QNAME_ATTR_NAME)
+    public IdentityAttributeRef(String qNameOfIdentity) {
+        if (qNameOfIdentity == null)
+            throw new NullPointerException("Parameter " + QNAME_ATTR_NAME + " is null");
+        this.qNameOfIdentity = qNameOfIdentity;
+    }
+
+    public String getqNameOfIdentity() {
+        return qNameOfIdentity;
+    }
+
+    public <T extends BaseIdentity> Class<? extends T> resolveIdentity(DependencyResolver resolver, Class<T> baseIdentity) {
+        return resolver.resolveIdentity(this, baseIdentity);
+    }
+
+    public <T extends BaseIdentity> void validateIdentity(DependencyResolver resolver, Class<T> baseIdentity, JmxAttribute jmxAttribute) {
+        resolver.validateIdentity(this, baseIdentity, jmxAttribute);
+    }
+
+    @Override
+    public String toString() {
+        final StringBuffer sb = new StringBuffer("IdentityAttributeRef{");
+        sb.append("qNameOfIdentity='").append(qNameOfIdentity).append('\'');
+        sb.append('}');
+        return sb.toString();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof IdentityAttributeRef)) return false;
+
+        IdentityAttributeRef that = (IdentityAttributeRef) o;
+
+        if (!qNameOfIdentity.equals(that.qNameOfIdentity)) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return qNameOfIdentity.hashCode();
+    }
+
+}