Skip to content

Commit 13c6a1b

Browse files
authored
Convert all Records to Classes (#221)
* Convert all Records to Classes * Remove Unused Suppression * Remove Desugar Imports * Review * Review: Make New Classes Final
1 parent 4347790 commit 13c6a1b

File tree

17 files changed

+806
-59
lines changed

17 files changed

+806
-59
lines changed

src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Category.java

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.cleanroommc.groovyscript.helper.recipe.IRecipeBuilder;
88
import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage;
99
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
10-
import com.github.bsideup.jabel.Desugar;
1110
import mezz.jei.api.IGuiHelper;
1211
import mezz.jei.api.IModRegistry;
1312
import mezz.jei.api.IRecipeRegistry;
@@ -19,6 +18,7 @@
1918
import java.util.ArrayList;
2019
import java.util.Collection;
2120
import java.util.List;
21+
import java.util.Objects;
2222
import java.util.function.Function;
2323

2424
@RegistryDescription(category = RegistryDescription.Category.ENTRIES,
@@ -115,11 +115,64 @@ public void hideAll() {
115115
hideAllCategories = true;
116116
}
117117

118-
@Desugar
119-
record CustomCategory(String id,
120-
Function<IGuiHelper, ? extends IRecipeCategory<? extends IRecipeWrapper>> category,
121-
List<?> catalysts,
122-
List<? extends IRecipeWrapper> wrappers) {
118+
@SuppressWarnings("ClassCanBeRecord")
119+
public static final class CustomCategory {
120+
121+
private final String id;
122+
private final Function<IGuiHelper, ? extends IRecipeCategory<? extends IRecipeWrapper>> category;
123+
private final List<?> catalysts;
124+
private final List<? extends IRecipeWrapper> wrappers;
125+
126+
public CustomCategory(String id,
127+
Function<IGuiHelper, ? extends IRecipeCategory<? extends IRecipeWrapper>> category,
128+
List<?> catalysts,
129+
List<? extends IRecipeWrapper> wrappers) {
130+
this.id = id;
131+
this.category = category;
132+
this.catalysts = catalysts;
133+
this.wrappers = wrappers;
134+
}
135+
136+
public String id() {
137+
return id;
138+
}
139+
140+
public Function<IGuiHelper, ? extends IRecipeCategory<? extends IRecipeWrapper>> category() {
141+
return category;
142+
}
143+
144+
public List<?> catalysts() {
145+
return catalysts;
146+
}
147+
148+
public List<? extends IRecipeWrapper> wrappers() {
149+
return wrappers;
150+
}
151+
152+
@Override
153+
public boolean equals(Object obj) {
154+
if (obj == this) return true;
155+
if (obj == null || obj.getClass() != this.getClass()) return false;
156+
var that = (CustomCategory) obj;
157+
return Objects.equals(this.id, that.id) &&
158+
Objects.equals(this.category, that.category) &&
159+
Objects.equals(this.catalysts, that.catalysts) &&
160+
Objects.equals(this.wrappers, that.wrappers);
161+
}
162+
163+
@Override
164+
public int hashCode() {
165+
return Objects.hash(id, category, catalysts, wrappers);
166+
}
167+
168+
@Override
169+
public String toString() {
170+
return "CustomCategory[" +
171+
"id=" + id + ", " +
172+
"category=" + category + ", " +
173+
"catalysts=" + catalysts + ", " +
174+
"wrappers=" + wrappers + ']';
175+
}
123176
}
124177

125178
public static class CategoryBuilder implements IRecipeBuilder<CustomCategory> {

src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ExplosionFurnaceAdditives.java

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
import com.cleanroommc.groovyscript.helper.ingredient.ItemsIngredient;
88
import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient;
99
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
10-
import com.github.bsideup.jabel.Desugar;
1110
import lykrast.prodigytech.common.recipe.ExplosionFurnaceManager;
1211
import net.minecraft.item.ItemStack;
1312

13+
import java.util.Objects;
14+
1415
@RegistryDescription(category = RegistryDescription.Category.ENTRIES)
1516
public class ExplosionFurnaceAdditives extends VirtualizedRegistry<ExplosionFurnaceAdditives.EFAdditiveRecipe> {
1617

@@ -87,8 +88,16 @@ public interface EFAdditiveRecipe {
8788
void unregister();
8889
}
8990

90-
@Desugar
91-
public record EFAdditiveExplosive(IIngredient input, int value) implements EFAdditiveRecipe {
91+
@SuppressWarnings("ClassCanBeRecord")
92+
public static final class EFAdditiveExplosive implements EFAdditiveRecipe {
93+
94+
private final IIngredient input;
95+
private final int value;
96+
97+
public EFAdditiveExplosive(IIngredient input, int value) {
98+
this.input = input;
99+
this.value = value;
100+
}
92101

93102
@Override
94103
public void register() {
@@ -111,10 +120,47 @@ public void unregister() {
111120
}
112121
}
113122
}
123+
124+
public IIngredient input() {
125+
return input;
126+
}
127+
128+
public int value() {
129+
return value;
130+
}
131+
132+
@Override
133+
public boolean equals(Object obj) {
134+
if (obj == this) return true;
135+
if (obj == null || obj.getClass() != this.getClass()) return false;
136+
var that = (EFAdditiveExplosive) obj;
137+
return Objects.equals(this.input, that.input) &&
138+
this.value == that.value;
139+
}
140+
141+
@Override
142+
public int hashCode() {
143+
return Objects.hash(input, value);
144+
}
145+
146+
@Override
147+
public String toString() {
148+
return "EFAdditiveExplosive[" +
149+
"input=" + input + ", " +
150+
"value=" + value + ']';
151+
}
114152
}
115153

116-
@Desugar
117-
public record EFAdditiveDampener(IIngredient input, int value) implements EFAdditiveRecipe {
154+
@SuppressWarnings("ClassCanBeRecord")
155+
public static final class EFAdditiveDampener implements EFAdditiveRecipe {
156+
157+
private final IIngredient input;
158+
private final int value;
159+
160+
public EFAdditiveDampener(IIngredient input, int value) {
161+
this.input = input;
162+
this.value = value;
163+
}
118164

119165
@Override
120166
public void register() {
@@ -137,5 +183,34 @@ public void unregister() {
137183
}
138184
}
139185
}
186+
187+
public IIngredient input() {
188+
return input;
189+
}
190+
191+
public int value() {
192+
return value;
193+
}
194+
195+
@Override
196+
public boolean equals(Object obj) {
197+
if (obj == this) return true;
198+
if (obj == null || obj.getClass() != this.getClass()) return false;
199+
var that = (EFAdditiveDampener) obj;
200+
return Objects.equals(this.input, that.input) &&
201+
this.value == that.value;
202+
}
203+
204+
@Override
205+
public int hashCode() {
206+
return Objects.hash(input, value);
207+
}
208+
209+
@Override
210+
public String toString() {
211+
return "EFAdditiveDampener[" +
212+
"input=" + input + ", " +
213+
"value=" + value + ']';
214+
}
140215
}
141216
}

src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ZorraAltar.java

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription;
66
import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription;
77
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
8-
import com.github.bsideup.jabel.Desugar;
98
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
109
import lykrast.prodigytech.common.recipe.ZorraAltarManager;
1110
import lykrast.prodigytech.common.util.Config;
1211
import net.minecraft.enchantment.Enchantment;
1312

1413
import java.util.Map;
14+
import java.util.Objects;
1515

1616

1717
@RegistryDescription
@@ -71,6 +71,50 @@ public boolean removeEnchantment(String registry, Enchantment enchantment) {
7171
return managers.get(registry).removeEnchant(enchantment);
7272
}
7373

74-
@Desugar
75-
public record ZorraRecipeData(String registry, Enchantment enchantment, int maxLevel) {}
74+
@SuppressWarnings("ClassCanBeRecord")
75+
public static final class ZorraRecipeData {
76+
77+
private final String registry;
78+
private final Enchantment enchantment;
79+
private final int maxLevel;
80+
81+
public ZorraRecipeData(String registry, Enchantment enchantment, int maxLevel) {
82+
this.registry = registry;
83+
this.enchantment = enchantment;
84+
this.maxLevel = maxLevel;
85+
}
86+
87+
public String registry() {return registry;}
88+
89+
public Enchantment enchantment() {
90+
return enchantment;
91+
}
92+
93+
public int maxLevel() {
94+
return maxLevel;
95+
}
96+
97+
@Override
98+
public boolean equals(Object obj) {
99+
if (obj == this) return true;
100+
if (obj == null || obj.getClass() != this.getClass()) return false;
101+
var that = (ZorraRecipeData) obj;
102+
return Objects.equals(this.registry, that.registry) &&
103+
Objects.equals(this.enchantment, that.enchantment) &&
104+
this.maxLevel == that.maxLevel;
105+
}
106+
107+
@Override
108+
public int hashCode() {
109+
return Objects.hash(registry, enchantment, maxLevel);
110+
}
111+
112+
@Override
113+
public String toString() {
114+
return "ZorraRecipeData[" +
115+
"registry=" + registry + ", " +
116+
"enchantment=" + enchantment + ", " +
117+
"maxLevel=" + maxLevel + ']';
118+
}
119+
}
76120
}

src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Coolant.java

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
import com.cleanroommc.groovyscript.core.mixin.thermalexpansion.CoolantManagerAccessor;
1010
import com.cleanroommc.groovyscript.helper.SimpleObjectStream;
1111
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
12-
import com.github.bsideup.jabel.Desugar;
1312
import mezz.jei.api.IGuiHelper;
1413
import net.minecraftforge.fluids.FluidStack;
1514
import org.jetbrains.annotations.ApiStatus;
1615

16+
import java.util.Objects;
17+
1718
@RegistryDescription(category = RegistryDescription.Category.ENTRIES,
1819
admonition = @Admonition(value = "groovyscript.wiki.thermalexpansion.coolant.note0", type = Admonition.Type.WARNING))
1920
public class Coolant extends VirtualizedRegistry<Coolant.CoolantRecipe> {
@@ -85,9 +86,53 @@ public void removeAll() {
8586
CoolantManagerAccessor.getCoolantFactorMap().clear();
8687
}
8788

88-
@Desugar
89-
public record CoolantRecipe(String fluid, int rf, int factor) {
89+
@SuppressWarnings("ClassCanBeRecord")
90+
public static final class CoolantRecipe {
91+
92+
private final String fluid;
93+
private final int rf;
94+
private final int factor;
95+
96+
public CoolantRecipe(String fluid, int rf, int factor) {
97+
this.fluid = fluid;
98+
this.rf = rf;
99+
this.factor = factor;
100+
}
101+
102+
public String fluid() {
103+
return fluid;
104+
}
105+
106+
public int rf() {
107+
return rf;
108+
}
90109

110+
public int factor() {
111+
return factor;
112+
}
113+
114+
@Override
115+
public boolean equals(Object obj) {
116+
if (obj == this) return true;
117+
if (obj == null || obj.getClass() != this.getClass()) return false;
118+
var that = (CoolantRecipe) obj;
119+
return Objects.equals(this.fluid, that.fluid) &&
120+
this.rf == that.rf &&
121+
this.factor == that.factor;
122+
}
123+
124+
@Override
125+
public int hashCode() {
126+
return Objects.hash(fluid, rf, factor);
127+
}
128+
129+
@Override
130+
public String toString() {
131+
return "CoolantRecipe[" +
132+
"fluid=" + fluid + ", " +
133+
"rf=" + rf + ", " +
134+
"factor=" + factor + ']';
135+
}
91136
}
92137

93138
}

0 commit comments

Comments
 (0)