Interface MemberCursor<N>
- Type Parameters:
N- the node type of the model
public interface MemberCursor<N>
Walks the members of one object, in order: the result of JsonModel.memberCursor(Object).
A cursor is for one walk, by one thread. It makes no list of the members and no Property
for each member, so a walk of a large object allocates almost nothing:
for (MemberCursor<N> cursor = model.memberCursor(object); cursor.next(); ) {
use(cursor.name(), cursor.value());
}
-
Method Summary
Modifier and TypeMethodDescriptionname()Returns the name of the current member.booleannext()Moves to the next member.static <N> MemberCursor<N> Returns a cursor over a sequence of properties.value()Returns the value of the current member.
-
Method Details
-
next
boolean next()Moves to the next member.- Returns:
trueif the cursor is on a member;falseat the end, and for each later call
-
name
JsonString name()Returns the name of the current member. Call it only after
next()returnedtrue.The caller can keep the name after the cursor moves, for example in a Normalized Path, so a model must not change a name that it gave.
- Returns:
- the member name
-
value
-
of
Returns a cursor over a sequence of properties.
Use it for a model whose objects are few or small, for example in a test. A model of large objects walks its own representation instead, so that a walk makes no
Propertyfor each member.- Type Parameters:
N- the node type of the model- Parameters:
properties- the members, in order- Returns:
- a new cursor before the first property
-