com.javanut.json.encode.JSONArraySelect Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pronghorn-pipes Show documentation
Show all versions of pronghorn-pipes Show documentation
Ring buffer based queuing utility for applications that require high performance and/or a small
footprint. Well suited for embedded and stream based processing.
package com.javanut.json.encode;
import com.javanut.json.encode.function.IterBoolFunction;
import com.javanut.json.encode.function.IteratorFunction;
public abstract class JSONArraySelect {
private final JSONBuilder builder;
private final IteratorFunction iterator;
private int count = 0;
private final IterBoolFunction[] branches = new IterBoolFunction[512];
private final JSONBuilder[] cases = new JSONBuilder[512];
public JSONArraySelect(JSONBuilder builder, IteratorFunction iterator) {
this.builder = builder;
this.iterator = iterator;
}
public JSONArray, N> tryCase(IterBoolFunction select) {
JSONArray, N> root = new JSONArray, N>(builder.tryCase(), iterator) {
@Override
JSONArraySelect arrayEnded() {
return JSONArraySelect.this;
}
};
cases[count] = root.builder;
branches[count] = select;
count++;
return root;
}
abstract P selectEnded();
public P endSelect() {
builder.endSelect(iterator, count, branches, cases);
return selectEnded();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy