io.jexxa.core.BootstrapService Maven / Gradle / Ivy
The newest version!
package io.jexxa.core;
import io.jexxa.common.facade.utils.annotation.CheckReturnValue;
import java.util.Objects;
import java.util.function.Consumer;
@SuppressWarnings("unused")
public class BootstrapService
{
private final Class bootstrapServiceClass;
private final JexxaMain jexxaMain;
BootstrapService(Class bootstrapService, JexxaMain jexxaMain)
{
this.bootstrapServiceClass = Objects.requireNonNull(bootstrapService);
this.jexxaMain = Objects.requireNonNull(jexxaMain);
}
@CheckReturnValue
public JexxaMain with(Consumer initFunction)
{
jexxaMain.addBootstrapService(bootstrapServiceClass, initFunction);
return jexxaMain;
}
@CheckReturnValue
public JexxaMain and()
{
jexxaMain.addBootstrapService(bootstrapServiceClass, noInitFunction());
return jexxaMain;
}
public static Consumer noInitFunction()
{
return element -> { /* just an empty function */};
}
}