Lazy#of -> Lazy#lazy

This commit is contained in:
dfsek
2021-07-24 20:14:19 -07:00
parent 074528003b
commit f73366fcb3
5 changed files with 5 additions and 10 deletions

View File

@@ -9,7 +9,7 @@ import java.util.Collection;
public interface EnumProperty<T extends Enum<T>> extends Property<T> {
static <T extends Enum<T>> EnumProperty<T> of(String name, Class<T> clazz) {
return new EnumProperty<T>() {
private final Lazy<Collection<T>> constants = Lazy.of(() -> Arrays.asList(clazz.getEnumConstants()));
private final Lazy<Collection<T>> constants = Lazy.lazy(() -> Arrays.asList(clazz.getEnumConstants()));
@Override
public Class<T> getType() {

View File

@@ -11,7 +11,7 @@ public final class Lazy<T> {
this.valueSupplier = valueSupplier;
}
public static <T> Lazy<T> of(Supplier<T> valueSupplier) {
public static <T> Lazy<T> lazy(Supplier<T> valueSupplier) {
return new Lazy<>(valueSupplier);
}

View File

@@ -9,13 +9,11 @@ import com.dfsek.terra.api.command.exception.MalformedCommandException;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.config.PluginConfig;
import com.dfsek.terra.api.event.EventManager;
import com.dfsek.terra.api.event.events.platform.PlatformInitializationEvent;
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
import com.dfsek.terra.api.lang.Language;
import com.dfsek.terra.api.profiler.Profiler;
import com.dfsek.terra.api.registry.CheckedRegistry;
import com.dfsek.terra.api.registry.Registry;
import com.dfsek.terra.api.util.generic.Construct;
import com.dfsek.terra.api.util.generic.Lazy;
import com.dfsek.terra.commands.CommandUtil;
import com.dfsek.terra.commands.TerraCommandManager;
@@ -39,7 +37,7 @@ import java.util.Optional;
* Skeleton implementation of {@link TerraPlugin}
*/
public abstract class AbstractTerraPlugin implements TerraPlugin {
private final Lazy<DebugLogger> debugLogger = Lazy.of(() -> new DebugLogger(logger()));
private final Lazy<DebugLogger> debugLogger = Lazy.lazy(() -> new DebugLogger(logger()));
private final EventManager eventManager = new EventManagerImpl(this);
private final ConfigRegistry configRegistry = new ConfigRegistry();

View File

@@ -8,7 +8,6 @@ import com.dfsek.terra.api.registry.meta.RegistryFactory;
import com.dfsek.terra.api.util.generic.Lazy;
import java.lang.reflect.AnnotatedType;
import java.lang.reflect.Type;
import java.util.function.Function;
public class RegistryFactoryImpl implements RegistryFactory {
@@ -20,7 +19,7 @@ public class RegistryFactoryImpl implements RegistryFactory {
@Override
public <T> OpenRegistry<T> create(Function<OpenRegistry<T>, TypeLoader<T>> loader) {
return new OpenRegistryImpl<>() {
private final Lazy<TypeLoader<T>> loaderCache = Lazy.of(() -> loader.apply(this));
private final Lazy<TypeLoader<T>> loaderCache = Lazy.lazy(() -> loader.apply(this));
@Override
public T load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException {

View File

@@ -5,10 +5,8 @@ import com.dfsek.tectonic.loading.TypeRegistry;
import com.dfsek.terra.AbstractTerraPlugin;
import com.dfsek.terra.api.Logger;
import com.dfsek.terra.api.addon.TerraAddon;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.handle.ItemHandle;
import com.dfsek.terra.api.handle.WorldHandle;
import com.dfsek.terra.api.lang.Language;
import com.dfsek.terra.api.util.generic.Lazy;
import com.dfsek.terra.config.lang.LangUtil;
import com.dfsek.terra.fabric.handle.FabricItemHandle;
@@ -44,7 +42,7 @@ public class TerraPluginImpl extends AbstractTerraPlugin {
private final ItemHandle itemHandle = new FabricItemHandle();
private final WorldHandle worldHandle = new FabricWorldHandle();
private final Lazy<File> dataFolder = Lazy.of(() -> new File(FabricLoader.getInstance().getConfigDir().toFile(), "Terra"));
private final Lazy<File> dataFolder = Lazy.lazy(() -> new File(FabricLoader.getInstance().getConfigDir().toFile(), "Terra"));
@Override
public WorldHandle getWorldHandle() {