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

com.javanut.json.encode.JSONSelect 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.ToBoolFunction;

public abstract class JSONSelect {
    private final JSONBuilder builder;
    private int count = 0;
    private final ToBoolFunction[] branches = new ToBoolFunction[512];
    private final JSONBuilder[] cases = new JSONBuilder[512];

    public JSONSelect(JSONBuilder builder) {
        this.builder = builder;
    }

    public JSONRoot> tryCase(ToBoolFunction select) {
        JSONRoot> root = new JSONRoot>(builder.tryCase()) {
            @Override
            JSONSelect rootEnded() {
                return JSONSelect.this;
            }
        };
        cases[count] = root.builder;
        branches[count] = select;
        count++;
        return root;
    }

    abstract P selectEnded();

    public P endSelect() {
        builder.endSelect(count, branches, cases);
        return selectEnded();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy