import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
-import java.util.Iterator;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
public final class DataSchemaContextTree {
private static final LoadingCache<SchemaContext, DataSchemaContextTree> TREES = CacheBuilder.newBuilder()
- .weakKeys()
- .build(new CacheLoader<SchemaContext, DataSchemaContextTree>() {
-
+ .weakKeys().weakValues().build(new CacheLoader<SchemaContext, DataSchemaContextTree>() {
@Override
public DataSchemaContextTree load(final SchemaContext key) throws Exception {
return new DataSchemaContextTree(key);
}
-
});
private final DataSchemaContextNode<?> root;
public DataSchemaContextNode<?> getChild(final YangInstanceIdentifier path) {
DataSchemaContextNode<?> currentOp = root;
- Iterator<PathArgument> arguments = path.getPathArguments().iterator();
- while (arguments.hasNext()) {
- currentOp = currentOp.getChild(arguments.next());
+ for (PathArgument arg : path.getPathArguments()) {
+ currentOp = currentOp.getChild(arg);
}
return currentOp;
}