Skip to content

Commit 8fb1f80

Browse files
committed
Use null instead of optional
1 parent bce134c commit 8fb1f80

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/client/java/aztech/modern_industrialization/machines/gui/MachineMenuClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private MachineMenuClient(int syncId, Inventory playerInventory, MIInventory inv
7575

7676
@Nullable
7777
public <T extends GuiComponentClient> T getComponent(Class<T> klass) {
78-
return components.get(klass).orElse(null);
78+
return components.get(klass);
7979
}
8080

8181
@Override

src/main/java/aztech/modern_industrialization/machines/ComponentStorage.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.function.Consumer;
3434
import java.util.function.Function;
3535
import net.minecraft.resources.ResourceLocation;
36+
import org.jetbrains.annotations.Nullable;
3637

3738
public sealed class ComponentStorage<C> implements Iterable<C> permits ComponentStorage.GuiServer, ComponentStorage.Server {
3839
protected final List<C> components = new ArrayList<>();
@@ -68,13 +69,14 @@ public final void forEachIndexed(BiConsumer<Integer, C> action) {
6869
}
6970
}
7071

71-
public final <T> Optional<T> get(Class<T> clazz) {
72+
@Nullable
73+
public final <T> T get(Class<T> clazz) {
7274
for (C component : components) {
7375
if (clazz.isInstance(component)) {
74-
return Optional.of((T) component);
76+
return (T) component;
7577
}
7678
}
77-
return Optional.empty();
79+
return null;
7880
}
7981

8082
public final <T> List<T> tryGet(Class<T> clazz) {

0 commit comments

Comments
 (0)