001package com.ericlam.mc.bungee.hnmc.function;
002
003import java.util.function.Consumer;
004import java.util.function.Supplier;
005
006public class ResultParser {
007    private boolean result;
008
009    private ResultParser(Supplier<Boolean> result) {
010        this.result = result.get();
011    }
012
013
014    public static ResultParser check(Supplier<Boolean> result) {
015        return new ResultParser(result);
016    }
017
018    public ResultParser execute(Consumer<Boolean> resultRunner) {
019        resultRunner.accept(result);
020        return this;
021    }
022
023    public ResultParser ifTrue(Runnable runnable) {
024        if (result) runnable.run();
025        return this;
026    }
027
028    public ResultParser ifFalse(Runnable runnable) {
029        if (!result) runnable.run();
030        return this;
031    }
032
033    public boolean getResult() {
034        return result;
035    }
036}