@Override public InstanceIdentifier<T> build() { Preconditions.checkState(arg != null, "No path arguments present"); final Iterable<PathArgument> pathArguments; if (basePath == null) { pathArguments = pathBuilder.build(); } else { pathArguments = Iterables.concat(basePath, pathBuilder.build()); } return InstanceIdentifier.trustedCreate(arg, pathArguments, hashBuilder.build(), wildcard); }
@Override public InstanceIdentifier<T> build() { Preconditions.checkState(arg != null, "No path arguments present"); final Iterable<PathArgument> pathArguments; if (basePath == null) { pathArguments = pathBuilder.build(); } else { pathArguments = Iterables.concat(basePath, pathBuilder.build()); } @SuppressWarnings("unchecked") final InstanceIdentifier<T> ret = (InstanceIdentifier<T>) InstanceIdentifier.trustedCreate(arg, pathArguments, hashBuilder.build(), wildcard); return ret; }
private <N extends DataObject> InstanceIdentifier<N> childIdentifier(final AbstractPathArgument<N> arg) { return trustedCreate(arg, Iterables.concat(pathArguments, Collections.singleton(arg)), HashCodeBuilder.nextHashCode(hash, arg), isWildcarded()); }
private InstanceIdentifier<?> childIdentifier(final PathArgument arg) { return trustedCreate(arg, Iterables.concat(pathArguments, Collections.singleton(arg)), HashCodeBuilder.nextHashCode(hash, arg), isWildcarded()); }
/** * Create an instance identifier for a very specific object type. This method implements {@link #create(Iterable)} * semantics, except it is used by internal callers, which have assured that the argument is an immutable Iterable. * * @param pathArguments The path to a specific node in the data tree * @return InstanceIdentifier instance * @throws IllegalArgumentException if pathArguments is empty or contains a null element. * @throws NullPointerException if {@code pathArguments} is null */ private static InstanceIdentifier<?> internalCreate(final Iterable<PathArgument> pathArguments) { final Iterator<? extends PathArgument> it = requireNonNull(pathArguments, "pathArguments may not be null") .iterator(); final HashCodeBuilder<PathArgument> hashBuilder = new HashCodeBuilder<>(); boolean wildcard = false; PathArgument arg = null; while (it.hasNext()) { arg = it.next(); checkArgument(arg != null, "pathArguments may not contain null elements"); // TODO: sanity check ChildOf<>; hashBuilder.addArgument(arg); if (Identifiable.class.isAssignableFrom(arg.getType()) && !(arg instanceof IdentifiableItem<?, ?>)) { wildcard = true; } } checkArgument(arg != null, "pathArguments may not be empty"); return trustedCreate(arg, pathArguments, hashBuilder.build(), wildcard); }
/** * Create an instance identifier for a very specific object type. This method * implements {@link #create(Iterable)} semantics, except it is used by internal * callers, which have assured that the argument is an immutable Iterable. * * * @param pathArguments The path to a specific node in the data tree * @return InstanceIdentifier instance * @throws IllegalArgumentException if pathArguments is empty or * contains a null element. */ private static InstanceIdentifier<?> internalCreate(final Iterable<PathArgument> pathArguments) { final Iterator<? extends PathArgument> it = Preconditions.checkNotNull(pathArguments, "pathArguments may not be null").iterator(); final HashCodeBuilder<PathArgument> hashBuilder = new HashCodeBuilder<>(); boolean wildcard = false; PathArgument a = null; while (it.hasNext()) { a = it.next(); Preconditions.checkArgument(a != null, "pathArguments may not contain null elements"); // TODO: sanity check ChildOf<>; hashBuilder.addArgument(a); if (Identifiable.class.isAssignableFrom(a.getType()) && !(a instanceof IdentifiableItem<?, ?>)) { wildcard = true; } } Preconditions.checkArgument(a != null, "pathArguments may not be empty"); return trustedCreate(a, pathArguments, hashBuilder.build(), wildcard); }