@Override public <T> List<T> findChildrenOfType(Class<T> targetType) { List<T> list = new ArrayList<>(); for (int i = 0; i < jjtGetNumChildren(); i++) { Node child = jjtGetChild(i); if (targetType.isInstance(child)) { list.add(targetType.cast(child)); } } return list; }
@Override public <T> T getFirstChildOfType(Class<T> childType) { int n = jjtGetNumChildren(); for (int i = 0; i < n; i++) { Node child = jjtGetChild(i); if (childType.isInstance(child)) { return childType.cast(child); } } return null; }
@Override public void removeChildAtIndex(final int childIndex) { if (0 <= childIndex && childIndex < jjtGetNumChildren()) { // Remove the child at the given index children = ArrayUtils.remove(children, childIndex); // Update the remaining & left-shifted children indexes for (int i = childIndex; i < jjtGetNumChildren(); i++) { jjtGetChild(i).jjtSetChildIndex(i); } } }
@Override public <T> List<T> findChildrenOfType(Class<T> targetType) { List<T> list = new ArrayList<>(); for (int i = 0; i < jjtGetNumChildren(); i++) { Node child = jjtGetChild(i); if (targetType.isInstance(child)) { list.add(targetType.cast(child)); } } return list; }
@Override public <T> T getFirstChildOfType(Class<T> childType) { int n = jjtGetNumChildren(); for (int i = 0; i < n; i++) { Node child = jjtGetChild(i); if (childType.isInstance(child)) { return childType.cast(child); } } return null; }
@Override public void removeChildAtIndex(final int childIndex) { if (0 <= childIndex && childIndex < jjtGetNumChildren()) { // Remove the child at the given index children = ArrayUtils.remove(children, childIndex); // Update the remaining & left-shifted children indexes for (int i = childIndex; i < jjtGetNumChildren(); i++) { jjtGetChild(i).jjtSetChildIndex(i); } } }