InstanceIdentifier implements Path<InstanceIdentifier<? extends DataObject>>,
        Immutable, Serializable { public final boolean containsWildcarded(final InstanceIdentifier<?> other) { requireNonNull(other, "other should not be null"); final Iterator<PathArgument> lit = pathArguments.iterator(); final Iterator<PathArgument> oit = other.pathArguments.iterator(); while (lit.hasNext()) { if (!oit.hasNext()) { return false; } final PathArgument la = lit.next(); final PathArgument oa = oit.next(); if (!la.getType().equals(oa.getType())) { return false; } if (la instanceof IdentifiableItem<?, ?> && oa instanceof IdentifiableItem<?, ?> && !la.equals(oa)) { return false; } } return true; } InstanceIdentifier(final Class<T> type, final Iterable<PathArgument> pathArguments, final boolean wildcarded,
            final int hash); final @NonNull Class<T> getTargetType(); @SuppressWarnings("unchecked") final InstanceIdentifier<N> verifyTarget(final Class<N> target); final @NonNull Iterable<PathArgument> getPathArguments(); final boolean isWildcarded(); @Override final int hashCode(); @Override final boolean equals(final Object obj); @Override final String toString(); final InstanceIdentifier<I> firstIdentifierOf(final Class<I> type); final K firstKeyOf(
            final Class<N> listItem); @Override final boolean contains(final InstanceIdentifier<? extends DataObject> other); final boolean containsWildcarded(final InstanceIdentifier<?> other); final InstanceIdentifier<N> child(final Class<N> container); @SuppressWarnings("unchecked") final KeyedInstanceIdentifier<N, K> child(final Class<N> listItem, final K listKey); final InstanceIdentifier<N> child(final Class<C> caze, final Class<N> container); @SuppressWarnings("unchecked") final KeyedInstanceIdentifier<N, K> child(
                final Class<C> caze, final Class<N> listItem, final K listKey); final InstanceIdentifier<N> augmentation(
            final Class<N> container); @NonNull InstanceIdentifierBuilder<T> builder(); static InstanceIdentifierBuilder<T> builder(
            final Class<T> container); static InstanceIdentifierBuilder<T> builder(final Class<C> caze, final Class<T> container); static InstanceIdentifierBuilder<N> builder(final Class<N> listItem,
                    final K listKey); static InstanceIdentifierBuilder<N> builder(final Class<C> caze, final Class<N> listItem,
                    final K listKey); static @NonNull InstanceIdentifier<?> create(final Iterable<? extends PathArgument> pathArguments); @SuppressWarnings("unchecked") static InstanceIdentifier<T> create(final Class<T> type); static K keyOf(
            final InstanceIdentifier<N> id);  }
@Test public void containsWildcarded() { final InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).build(); final InstanceIdentifier<Node> wildcarded = InstanceIdentifier.builder(Nodes.class).child(Node.class).build(); final InstanceIdentifier<NodeChild> wildcardedChildren = InstanceIdentifier.builder(Nodes.class) .child(Node.class) .child(NodeChild.class).build(); assertTrue(wildcarded.isWildcarded()); assertTrue(wildcardedChildren.isWildcarded()); final InstanceIdentifier<Node> nodeTen = InstanceIdentifier.builder(Nodes.class) .child(Node.class,new NodeKey(10)).build(); final InstanceIdentifier<Node> nodeOne = InstanceIdentifier.builder(Nodes.class) .child(Node.class,new NodeKey(1)).build(); assertFalse(nodeTen.isWildcarded()); assertFalse(nodeOne.isWildcarded()); assertTrue(nodes.containsWildcarded(nodeOne)); assertTrue(wildcarded.containsWildcarded(nodeOne)); assertTrue(wildcarded.containsWildcarded(nodeTen)); assertFalse(InstanceIdentifier.builder(Nodes.class) .child(InstantiatedFoo.class).build().containsWildcarded(wildcarded)); final InstanceIdentifier<NodeChild> nodeTenChildWildcarded = InstanceIdentifier.builder(Nodes.class) .child(Node.class,new NodeKey(10)).child(NodeChild.class).build(); assertTrue(nodeTenChildWildcarded.isWildcarded()); final InstanceIdentifier<NodeChild> nodeTenChild = InstanceIdentifier.builder(Nodes.class) .child(Node.class,new NodeKey(10)).child(NodeChild.class, new NodeChildKey(10)).build(); final InstanceIdentifier<NodeChild> nodeOneChild = InstanceIdentifier.builder(Nodes.class) .child(Node.class,new NodeKey(1)).child(NodeChild.class, new NodeChildKey(1)).build(); assertFalse(nodeTenChildWildcarded.containsWildcarded(nodeOneChild)); assertTrue(nodeTenChildWildcarded.containsWildcarded(nodeTenChild)); }