childAt(int) is a better name for this method, as it does not conflict
with other possible uses. Also move the FIXME related to body() type
override to the top of the class and make sure it does not contain
commented-out code.
JIRA: YANGTOOLS-1022
Change-Id: I583ede8fdd7e91748775475470b09c94b54d8cfe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
*
* @param <V> child type
*/
*
* @param <V> child type
*/
+// FIXME: 8.0.0: we really want to do a List<@NonNull V> body(), but need to reconcile that with key-based lookup in
+// implementations -- and those are using only a Map internally.
public interface OrderedNodeContainer<V extends NormalizedNode>
extends NormalizedNodeContainer<V>, MixinNode, OrderingAware.User {
@Override
public interface OrderedNodeContainer<V extends NormalizedNode>
extends NormalizedNodeContainer<V>, MixinNode, OrderingAware.User {
@Override
* @return Child Node
* @throws IndexOutOfBoundsException Out of bound Exception
*/
* @return Child Node
* @throws IndexOutOfBoundsException Out of bound Exception
*/
- // FIXME: 7.0.0: rename to 'childAt(int)'
- @NonNull V getChild(int position);
-
- // FIXME: 7.0.0: do we really mean 'List' for body?
- // @Override
- // List<V> body();
+ @NonNull V childAt(int position);
@Override
int hashCode();
@Override
int hashCode();
- * The implementation is required to define a user-visible iteration order, which must match {@link #getChild(int)}.
+ * The implementation is required to define a user-visible iteration order, which must match {@link #childAt(int)}.
*/
@Override
Map<NodeIdentifierWithPredicates, MapEntryNode> asMap();
*/
@Override
Map<NodeIdentifierWithPredicates, MapEntryNode> asMap();
assertTrue(transformedInput instanceof UnkeyedListNode);
final UnkeyedListNode hop = (UnkeyedListNode) transformedInput;
assertTrue(transformedInput instanceof UnkeyedListNode);
final UnkeyedListNode hop = (UnkeyedListNode) transformedInput;
- final DataContainerChild lrsBits = hop.getChild(0).childByArg(
+ final DataContainerChild lrsBits = hop.childAt(0).childByArg(
NodeIdentifier.create(QName.create("foo", "lrs-bits")));
assertEquals(ImmutableSet.of("lookup", "rloc-probe", "strict"), lrsBits.body());
NodeIdentifier.create(QName.create("foo", "lrs-bits")));
assertEquals(ImmutableSet.of("lookup", "rloc-probe", "strict"), lrsBits.body());
- public UnkeyedListEntryNode getChild(final int position) {
+ public UnkeyedListEntryNode childAt(final int position) {
throw new IndexOutOfBoundsException();
}
throw new IndexOutOfBoundsException();
}
- public UnkeyedListEntryNode getChild(final int position) {
+ public UnkeyedListEntryNode childAt(final int position) {
return children.get(position);
}
return children.get(position);
}
- public LeafSetEntryNode<T> getChild(final int position) {
+ public LeafSetEntryNode<T> childAt(final int position) {
return Iterables.get(children.values(), position);
}
return Iterables.get(children.values(), position);
}
- public MapEntryNode getChild(final int position) {
+ public MapEntryNode childAt(final int position) {
return Iterables.get(children.values(), position);
}
return Iterables.get(children.values(), position);
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.mock;
import java.io.File;
import static org.mockito.Mockito.mock;
import java.io.File;
assertEquals(SIZE, orderedMapNodeCreateNull.size());
assertEquals(orderedMapNodeCreateNode.size(), orderedMapNodeCreateNull.size() - 1);
assertEquals(NODE_IDENTIFIER_LIST, orderedMapNodeCreateSize.getIdentifier());
assertEquals(SIZE, orderedMapNodeCreateNull.size());
assertEquals(orderedMapNodeCreateNode.size(), orderedMapNodeCreateNull.size() - 1);
assertEquals(NODE_IDENTIFIER_LIST, orderedMapNodeCreateSize.getIdentifier());
- assertEquals(LIST_MAIN_CHILD_1, orderedMapNodeCreateNull.getChild(0));
+ assertEquals(LIST_MAIN_CHILD_1, orderedMapNodeCreateNull.childAt(0));
assertEquals(SIZE, orderedMapNodeCreateNull.size());
assertEquals(SIZE, orderedMapNodeCreateNull.size());
- assertEquals(orderedMapNodeSchemaAware.getChild(0), orderedMapNodeSchemaAwareMapNodeConst.getChild(0));
+ assertEquals(orderedMapNodeSchemaAware.childAt(0), orderedMapNodeSchemaAwareMapNodeConst.childAt(0));
assertNotNull(Builders.anyXmlBuilder());
assertNotNull(orderedLeafSetShemaAware);
assertEquals(1, ((UserLeafSetNode<?>)orderedLeafSet).size());
assertNotNull(Builders.anyXmlBuilder());
assertNotNull(orderedLeafSetShemaAware);
assertEquals(1, ((UserLeafSetNode<?>)orderedLeafSet).size());
- assertEquals("baz", orderedLeafSet.getChild(0).body());
+ assertEquals("baz", orderedLeafSet.childAt(0).body());
assertNull(orderedLeafSet.childByArg(BAR_PATH));
assertEquals(1, leafSetCollection.size());
assertEquals(1, SchemaAwareleafSetCollection.size());
assertNull(orderedLeafSet.childByArg(BAR_PATH));
assertEquals(1, leafSetCollection.size());
assertEquals(1, SchemaAwareleafSetCollection.size());
.build();
final UnkeyedListNode unkeyedListNodeCreated = ImmutableUnkeyedListNodeBuilder.create(unkeyedListNode)
.build();
.build();
final UnkeyedListNode unkeyedListNodeCreated = ImmutableUnkeyedListNodeBuilder.create(unkeyedListNode)
.build();
- try {
- unkeyedListNodeSize.getChild(1);
- } catch (IndexOutOfBoundsException e) {
- // Ignored on purpose
- }
+
+ assertThrows(IndexOutOfBoundsException.class, () -> unkeyedListNodeSize.childAt(1));
assertNotNull(unkeyedListNodeSize.body());
assertNotNull(unkeyedListNodeSize.body());
- assertEquals(unkeyedListEntryNode, unkeyedListNodeCreated.getChild(0));
- assertEquals(unkeyedListNode.getNodeType().getLocalName(), unkeyedListNodeSize.getNodeType()
- .getLocalName());
+ assertEquals(unkeyedListEntryNode, unkeyedListNodeCreated.childAt(0));
+ assertEquals(unkeyedListNode.getNodeType().getLocalName(), unkeyedListNodeSize.getNodeType().getLocalName());
assertNotNull(unkeyedListNodeCreated);
}
assertNotNull(unkeyedListNodeCreated);
}