com.redhat.lightblue.metadata.FieldCursor Maven / Gradle / Ivy
/*
Copyright 2013 Red Hat, Inc. and/or its affiliates.
This file is part of lightblue.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
package com.redhat.lightblue.metadata;
import com.redhat.lightblue.util.AbstractTreeCursor;
import com.redhat.lightblue.util.KeyValueCursor;
import com.redhat.lightblue.util.Path;
import java.util.Iterator;
public class FieldCursor extends AbstractTreeCursor {
private static final class Adapter implements KeyValueCursor {
private final Iterator extends FieldTreeNode> itr;
private FieldTreeNode node;
public Adapter(Iterator extends FieldTreeNode> itr) {
this.itr = itr;
}
@Override
public boolean hasNext() {
return itr.hasNext();
}
@Override
public void next() {
node = itr.next();
}
@Override
public String getCurrentKey() {
return node.getName();
}
@Override
public FieldTreeNode getCurrentValue() {
return node;
}
}
public FieldCursor(Path p, FieldTreeNode start) {
super(p, start);
}
@Override
protected KeyValueCursor getCursor(FieldTreeNode node) {
return new Adapter(node.getChildren());
}
@Override
protected boolean hasChildren(FieldTreeNode node) {
return node.hasChildren();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy