2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.binding;
11 * An {@link InstanceIdentifier}, which has a list key attached at its last path
14 * @param <T> Target data type
15 * @param <K> Target key type
17 public class KeyedInstanceIdentifier<T extends Identifiable<K> & DataObject, K extends Identifier<T>> extends InstanceIdentifier<T> {
18 private static final long serialVersionUID = 1L;
21 KeyedInstanceIdentifier(final Class<T> type, final Iterable<PathArgument> pathArguments, final boolean wildcarded, final int hash, final K key) {
22 super(type, pathArguments, wildcarded, hash);
27 * Return the key attached to this identifier. This method is equivalent to
28 * calling {@link InstanceIdentifier#keyOf(InstanceIdentifier)}.
30 * @return Key associated with this instance identifier.
32 public final K getKey() {
37 public final InstanceIdentifierBuilder<T> builder() {
38 return new InstanceIdentifierBuilderImpl<T>(new InstanceIdentifier.IdentifiableItem<T, K>(getTargetType(), key), pathArguments, hashCode(), isWildcarded());
42 protected boolean fastNonEqual(final InstanceIdentifier<?> other) {
43 final KeyedInstanceIdentifier<?, ?> kii = (KeyedInstanceIdentifier<?, ?>) other;
46 * We could do an equals() here, but that may actually be expensive.
47 * equals() in superclass falls back to a full compare, which will
48 * end up running that equals anyway, so do not bother here.
50 return (key == null) != (kii.key == null);