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

com.bigcustard.glide.code.command.NewCommand Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.bigcustard.glide.code.command;

import com.bigcustard.glide.code.language.Language;
import com.bigcustard.scene2dplus.command.AbstractCommand;
import com.bigcustard.util.FutureSupplier;
import com.bigcustard.util.FutureSuppliers;

import java.util.function.Consumer;

public class NewCommand extends AbstractCommand {
    private final FutureSupplier gameLanguageSupplier;
    private final Consumer newGame;
    private final Runnable cancel;

    public NewCommand(FutureSupplier gameLanguageSupplier, Consumer newGame, Runnable cancel) {
        this.gameLanguageSupplier = gameLanguageSupplier;
        this.newGame = newGame;
        this.cancel = cancel;
    }

    @Override
    public void execute() {
       FutureSuppliers.onGet(gameLanguageSupplier, (language) -> {
           if (language != null) {
               newGame.accept(language);
           } else {
               cancel.run();
           }
       });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy