/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
package org.opendaylight.yangtools.yang.data.api;
import com.google.common.base.Preconditions;
+import com.google.common.base.Verify;
import com.google.common.collect.UnmodifiableIterator;
import java.util.Iterator;
import java.util.List;
+import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
final class StackedPathArguments extends PathArgumentList {
private final List<PathArgument> base;
private final List<PathArgument> stack;
- public StackedPathArguments(final YangInstanceIdentifier base, final List<PathArgument> stack) {
+ public StackedPathArguments(@Nonnull final YangInstanceIdentifier base, @Nonnull final List<PathArgument> stack) {
+ Verify.verify(!stack.isEmpty());
this.base = base.getPathArguments();
- this.stack = Preconditions.checkNotNull(stack);
+ this.stack = stack;
}
@Override
}
@Override
- public final PathArgument get(final int index) {
+ public PathArgument get(final int index) {
if (index < base.size()) {
return base.get(index);
- } else {
- return stack.get(index - base.size());
}
+ return stack.get(index - base.size());
}
@Override
- public final int indexOf(final Object o) {
+ public int indexOf(final Object o) {
final PathArgument srch = (PathArgument) Preconditions.checkNotNull(o);
int ret = base.indexOf(srch);
}
@Override
- public final int lastIndexOf(final Object o) {
+ public int lastIndexOf(final Object o) {
final PathArgument srch = (PathArgument) Preconditions.checkNotNull(o);
final int ret = stack.lastIndexOf(srch);