host.anzo.core.startup.StartupInstance Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-core Show documentation
Show all versions of commons-core Show documentation
Commons library to make me happy.
package host.anzo.core.startup;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
import java.util.*;
/**
* @author ANZO
*/
@Slf4j
public class StartupInstance> {
private final HashMap>> startTable = new HashMap<>();
void put(SL level, StartModule module) {
List> invokes = startTable.computeIfAbsent(level, k -> new ArrayList<>());
invokes.add(module);
}
protected Collection>>> getAll() {
return startTable.entrySet();
}
protected @Nullable List> get(SL level) {
return startTable.getOrDefault(level, null);
}
void runLevel(SL level) {
final List> list = startTable.get(level);
if(list == null) {
return;
}
list.forEach(StartModule::init);
}
boolean levelExists(SL level) {
return startTable.get(level) != null && !startTable.get(level).isEmpty();
}
}