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.mdsal.binding2.spec;
10 import com.google.common.annotations.Beta;
13 * An {@link InstanceIdentifier}, which has a list key attached at its last path
16 * @param <T> Target data type
17 * @param <K> Target key type
21 public class KeyedInstanceIdentifier<T extends TreeNode, K> extends InstanceIdentifier<T> {
22 private static final long serialVersionUID = 1L;
25 KeyedInstanceIdentifier(final Class<T> type, final Iterable<TreeArgument> pathArguments, final boolean wildcarded, final int hash, final K key) {
26 super(type, pathArguments, wildcarded, hash);
31 * Return the key attached to this identifier. This method is equivalent to
32 * calling {@link InstanceIdentifier#keyOf(InstanceIdentifier)}.
34 * @return Key associated with this instance identifier.
36 public final K getKey() {
41 public final InstanceIdentifierBuilder<T> builder() {
42 return new InstanceIdentifierBuilderImpl<T>(new IdentifiableItem<T, K>(getTargetType(), key), pathArguments,
43 hashCode(), isWildcarded());
47 protected boolean fastNonEqual(final InstanceIdentifier<?> other) {
48 final KeyedInstanceIdentifier<?, ?> kii = (KeyedInstanceIdentifier<?, ?>) other;
51 * We could do an equals() here, but that may actually be expensive.
52 * equals() in superclass falls back to a full compare, which will
53 * end up running that equals anyway, so do not bother here.
55 return (key == null) != (kii.key == null);