+ /**
+ * Create a builder rooted at this key.
+ *
+ * @return A builder instance
+ */
+ public InstanceIdentifierBuilder<T> builder() {
+ return new InstanceIdentifierBuilderImpl<T>(new Item<T>(targetType), pathArguments, hash, isWildcarded());
+ }
+
+ private InstanceIdentifier<?> childIdentifier(final PathArgument arg) {
+ return trustedCreate(arg, Iterables.concat(pathArguments, Collections.singleton(arg)), HashCodeBuilder.nextHashCode(hash, arg), isWildcarded());
+ }
+
+ @SuppressWarnings("unchecked")
+ public final <N extends ChildOf<? super T>> InstanceIdentifier<N> child(final Class<N> container) {
+ final PathArgument arg = new Item<>(container);
+ return (InstanceIdentifier<N>) childIdentifier(arg);
+ }
+
+ @SuppressWarnings("unchecked")
+ public final <N extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<N>> KeyedInstanceIdentifier<N, K> child(
+ final Class<N> listItem, final K listKey) {
+ final PathArgument arg = new IdentifiableItem<>(listItem, listKey);
+ return (KeyedInstanceIdentifier<N, K>) childIdentifier(arg);
+ }
+
+ @SuppressWarnings("unchecked")
+ public final <N extends DataObject & Augmentation<? super T>> InstanceIdentifier<N> augmentation(
+ final Class<N> container) {
+ final PathArgument arg = new Item<>(container);
+ return (InstanceIdentifier<N>) childIdentifier(arg);
+ }
+
+ @Deprecated
+ private List<PathArgument> legacyCache;
+
+ /**
+ * @deprecated Use {@link #getPathArguments()} instead.
+ */
+ @Deprecated
+ public final List<PathArgument> getPath() {
+ if (legacyCache == null) {
+ legacyCache = ImmutableList.<PathArgument>copyOf(pathArguments);