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

net.hamnaberg.json.VoidFolder Maven / Gradle / Ivy

There is a newer version: 8.0.0-RC1
Show newest version
package net.hamnaberg.json;

import java.util.function.Consumer;

public interface VoidFolder {
    default void onNull() {
    }

    default void onBoolean(Json.JBoolean b) {
    }

    default void onNumber(Json.JNumber n) {
    }

    default void onString(Json.JString s) {
    }

    default void onArray(Json.JArray a) {
    }

    default void onObject(Json.JObject o) {
    }

    static VoidFolder from(Consumer fString, Consumer fBoolean, Consumer fNumber, Consumer fObject, Consumer fArray, Runnable fNull) {
        return new VoidFolder() {
            @Override
            public void onNull() {
                fNull.run();
            }

            @Override
            public void onBoolean(Json.JBoolean b) {
                fBoolean.accept(b);
            }

            @Override
            public void onNumber(Json.JNumber n) {
                fNumber.accept(n);
            }

            @Override
            public void onString(Json.JString s) {
                fString.accept(s);
            }

            @Override
            public void onArray(Json.JArray a) {
                fArray.accept(a);
            }

            @Override
            public void onObject(Json.JObject o) {
                fObject.accept(o);
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy