-/*
- * 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.yangtools.yang.binding;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Uniquely identifies instance of data tree.
- *
- *
- */
-public class InstanceIdentifier {
-
- private final List<PathArgument> path;
- private final Class<? extends DataObject> targetType;
-
- public InstanceIdentifier(Class<? extends DataObject> type) {
- path = Collections.emptyList();
- this.targetType = type;
- }
-
- public InstanceIdentifier(List<PathArgument> path, Class<? extends DataObject> type) {
- this.path = Collections.<PathArgument> unmodifiableList(new ArrayList<>(path));
- this.targetType = type;
- }
-
- /**
- *
- * @return
- */
- public List<PathArgument> getPath() {
- return this.path;
- }
-
- public Class<?> getTargetType() {
- return this.targetType;
- }
-
- /**
- * Path argument of instance identifier.
- *
- * Interface which implementations are used as path components of the
- * instance path.
- *
- * @author ttkacik
- *
- */
- interface PathArgument {
-
- }
-
- public static class IdentifiableItem<I extends Identifiable<T>, T extends Identifier<I>> implements PathArgument {
-
- private final T key;
- private final Class<? extends I> type;
-
- public IdentifiableItem(Class<I> type, T key) {
- this.type = type;
- this.key = key;
- }
-
- T getKey() {
- return this.key;
- }
-
- Class<? extends I> getType() {
- return this.type;
- }
- }
-}
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.yangtools.yang.binding;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+/**\r
+ * Uniquely identifies instance of data tree.\r
+ * \r
+ * \r
+ */\r
+public class InstanceIdentifier {\r
+\r
+ private final List<PathArgument> path;\r
+ private final Class<? extends DataObject> targetType;\r
+\r
+ public InstanceIdentifier(Class<? extends DataObject> type) {\r
+ path = Collections.emptyList();\r
+ this.targetType = type;\r
+ }\r
+\r
+ public InstanceIdentifier(List<PathArgument> path, Class<? extends DataObject> type) {\r
+ this.path = Collections.<PathArgument> unmodifiableList(new ArrayList<>(path));\r
+ this.targetType = type;\r
+ }\r
+\r
+ /**\r
+ * \r
+ * @return\r
+ */\r
+ public List<PathArgument> getPath() {\r
+ return this.path;\r
+ }\r
+\r
+ public Class<?> getTargetType() {\r
+ return this.targetType;\r
+ }\r
+ \r
+ \r
+ \r
+ \r
+ @Override\r
+ public String toString() {\r
+ return "InstanceIdentifier [path=" + path + "]";\r
+ }\r
+\r
+ /**\r
+ * Path argument of instance identifier.\r
+ * \r
+ * Interface which implementations are used as path components of the\r
+ * instance path.\r
+ * \r
+ * @author ttkacik\r
+ * \r
+ */\r
+ public interface PathArgument {\r
+\r
+ }\r
+\r
+ public static class IdentifiableItem<I extends Identifiable<T>, T extends Identifier<I>> implements PathArgument {\r
+\r
+ private final T key;\r
+ private final Class<? extends I> type;\r
+\r
+ public IdentifiableItem(Class<I> type, T key) {\r
+ this.type = type;\r
+ this.key = key;\r
+ }\r
+\r
+ T getKey() {\r
+ return this.key;\r
+ }\r
+\r
+ Class<? extends I> getType() {\r
+ return this.type;\r
+ }\r
+ \r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if(obj == null) {\r
+ return false;\r
+ }\r
+ if(obj.hashCode() != hashCode()) {\r
+ return false;\r
+ }\r
+ if(!(obj instanceof IdentifiableItem<?, ?>)) {\r
+ return false;\r
+ }\r
+ IdentifiableItem<?, ?> foreign = (IdentifiableItem<?, ?>) obj;\r
+ return key.equals(foreign.getKey());\r
+ }\r
+ \r
+ @Override\r
+ public int hashCode() {\r
+ return key.hashCode();\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return "IdentifiableItem [key=" + key + "]";\r
+ }\r
+ }\r
+}\r