/* * Copyright (c) 2014 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; public class KeyedInstanceIdentifier & DataObject, K extends Identifier> extends InstanceIdentifier { private final K key; KeyedInstanceIdentifier(final Class type, final Iterable pathArguments, final boolean wildcarded, final int hash, final K key) { super(type, pathArguments, wildcarded, hash); this.key = key; } public final K getKey() { return key; } @Override public final InstanceIdentifierBuilder builder() { return new InstanceIdentifierBuilderImpl(new InstanceIdentifier.IdentifiableItem(getTargetType(), key), getPathArguments(), hashCode(), isWildcarded()); } @Override protected boolean fastNonEqual(final InstanceIdentifier other) { final KeyedInstanceIdentifier kii = (KeyedInstanceIdentifier) other; /* * We could do an equals() here, but that may actually be expensive. * equals() in superclass falls back to a full compare, which will * end up running that equals anyway, so do not bother here. */ return (key == null) != (kii.key == null); } }