2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package org.opendaylight.yangtools.yang.binding;
\r
10 import java.util.ArrayList;
\r
11 import java.util.Collections;
\r
12 import java.util.List;
\r
15 * Uniquely identifies instance of data tree.
\r
19 public class InstanceIdentifier {
\r
21 private final List<PathArgument> path;
\r
22 private final Class<? extends DataObject> targetType;
\r
24 public InstanceIdentifier(Class<? extends DataObject> type) {
\r
25 path = Collections.emptyList();
\r
26 this.targetType = type;
\r
29 public InstanceIdentifier(List<PathArgument> path, Class<? extends DataObject> type) {
\r
30 this.path = Collections.<PathArgument> unmodifiableList(new ArrayList<>(path));
\r
31 this.targetType = type;
\r
38 public List<PathArgument> getPath() {
\r
42 public Class<?> getTargetType() {
\r
43 return this.targetType;
\r
50 public String toString() {
\r
51 return "InstanceIdentifier [path=" + path + "]";
\r
55 * Path argument of instance identifier.
\r
57 * Interface which implementations are used as path components of the
\r
63 public interface PathArgument {
\r
67 public static class IdentifiableItem<I extends Identifiable<T>, T extends Identifier<I>> implements PathArgument {
\r
69 private final T key;
\r
70 private final Class<? extends I> type;
\r
72 public IdentifiableItem(Class<I> type, T key) {
\r
81 Class<? extends I> getType() {
\r
86 public boolean equals(Object obj) {
\r
90 if(obj.hashCode() != hashCode()) {
\r
93 if(!(obj instanceof IdentifiableItem<?, ?>)) {
\r
96 IdentifiableItem<?, ?> foreign = (IdentifiableItem<?, ?>) obj;
\r
97 return key.equals(foreign.getKey());
\r
101 public int hashCode() {
\r
102 return key.hashCode();
\r
106 public String toString() {
\r
107 return "IdentifiableItem [key=" + key + "]";
\r