All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.javanut.json.encode.JSONArraySelect Maven / Gradle / Ivy

Go to download

Ring buffer based queuing utility for applications that require high performance and/or a small footprint. Well suited for embedded and stream based processing.

There is a newer version: 1.1.27
Show newest version
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