2 * Copyright (c) 2017 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
9 package org.opendaylight.mdsal.binding.javav2.spec.base;
11 import com.google.common.annotations.Beta;
14 * An {@link InstanceIdentifier}, which has a list key attached at its last path
17 * @param <T> Target data type
18 * @param <K> Target key type
22 public class KeyedInstanceIdentifier<T extends TreeNode, K> extends InstanceIdentifier<T> {
23 private static final long serialVersionUID = 1L;
26 KeyedInstanceIdentifier(final Class<T> type, final Iterable<TreeArgument> pathArguments, final boolean wildcarded, final int hash, final K key) {
27 super(type, pathArguments, wildcarded, hash);
32 * Return the key attached to this identifier. This method is equivalent to
33 * calling {@link InstanceIdentifier#keyOf(InstanceIdentifier)}.
35 * @return Key associated with this instance identifier.
37 public final K getKey() {
42 public final InstanceIdentifierBuilder<T> builder() {
43 return new InstanceIdentifierBuilderImpl<T>(new IdentifiableItem<T, K>(getTargetType(), key), pathArguments,
44 hashCode(), isWildcarded());
48 protected boolean fastNonEqual(final InstanceIdentifier<?> other) {
49 final KeyedInstanceIdentifier<?, ?> kii = (KeyedInstanceIdentifier<?, ?>) other;
52 * We could do an equals() here, but that may actually be expensive.
53 * equals() in superclass falls back to a full compare, which will
54 * end up running that equals anyway, so do not bother here.
56 return (key == null) != (kii.key == null);