Skip to content

Commit

Permalink
objectMapper() -> objectMapperBuilder()
Browse files Browse the repository at this point in the history
  • Loading branch information
brachy84 committed Jun 10, 2024
1 parent 7d67f75 commit f5899a0
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void addPropertiesOfFields(Object o, boolean privateToo) {
}
}

public <V> ObjectMapper.Builder<V> objectMapper(String name, Class<V> returnType) {
public <V> ObjectMapper.Builder<V> objectMapperBuilder(String name, Class<V> returnType) {
return new ObjectMapper.Builder<>(name, returnType).mod(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class Alchemistry extends GroovyPropertyContainer {

@Override
public void initialize(GroovyContainer<?> container) {
container.objectMapper("element", ItemStack.class)
container.objectMapperBuilder("element", ItemStack.class)
.parser((s, args) -> {
String parsedName = s.trim().toLowerCase().replace(" ", "_");
ChemicalCompound compound = CompoundRegistry.INSTANCE.get(parsedName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class AppliedEnergistics2 extends GroovyPropertyContainer {

@Override
public void initialize(GroovyContainer<?> container) {
container.objectMapper("tunnel", TunnelType.class)
container.objectMapperBuilder("tunnel", TunnelType.class)
.parser(IObjectParser.wrapEnum(TunnelType.class, false))
.completerOfNamed(() -> Arrays.asList(TunnelType.values()), v -> v.name().toUpperCase(Locale.ROOT))
.docOfType("P2P tunnel type")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class AstralSorcery extends GroovyPropertyContainer {

@Override
public void initialize(GroovyContainer<?> container) {
container.objectMapper("constellation", IConstellation.class)
container.objectMapperBuilder("constellation", IConstellation.class)
.parser((s, args) -> {
for (IConstellation constellation : ConstellationRegistryAccessor.getConstellationList()) {
if (constellation.getSimpleName().equalsIgnoreCase(s)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static LexiconEntry getEntry(String name) {
@SuppressWarnings("Convert2MethodRef")
@Override
public void initialize(GroovyContainer<?> container) {
container.objectMapper("brew", vazkii.botania.api.brew.Brew.class)
container.objectMapperBuilder("brew", vazkii.botania.api.brew.Brew.class)
.parser(IObjectParser.wrapStringGetter(val -> BotaniaAPI.brewMap.get(val), false))
.completerOfNames(() -> BotaniaAPI.brewMap.keySet())
.defaultValue(() -> BotaniaAPI.fallbackBrew)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class EvilCraft extends GroovyPropertyContainer {
@Override
public void initialize(GroovyContainer<?> container) {
final List<String> weatherTypes = Arrays.asList("any", "clear", "rain", "lightning");
container.objectMapper("weather", WeatherType.class)
container.objectMapperBuilder("weather", WeatherType.class)
.parser(IObjectParser.wrapStringGetter(WeatherType::valueOf, true))
.completerOfNames(() -> weatherTypes) // elements don't have names
.defaultValue(() -> WeatherType.ANY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected static String getNormalName(String name) {

@Override
public void initialize(GroovyContainer<?> container) {
container.objectMapper("species", AlleleBeeSpecies.class)
container.objectMapperBuilder("species", AlleleBeeSpecies.class)
.parser(Forestry::parseSpecies)
.completerOfNamed(() -> AlleleManager.alleleRegistry.getRegisteredAlleles().keySet(), s -> s.replace('.', ':')) // elements don't have names
.docOfType("allele bee species")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public class Mekanism extends GroovyPropertyContainer {

@Override
public void initialize(GroovyContainer<?> container) {
container.objectMapper("gas", GasStack.class)
container.objectMapperBuilder("gas", GasStack.class)
.parser((s, args) -> {
Gas gas = GasRegistry.getGas(s);
return gas == null ? Result.error() : Result.some(new GasStack(gas, 1));
})
.completerOfNamed(GasRegistry::getRegisteredGasses, Gas::getName)
.docOfType("gas stack")
.register();
container.objectMapper("infusionType", InfuseType.class) // infusion clashes with infusion field
container.objectMapperBuilder("infusionType", InfuseType.class) // infusion clashes with infusion field
.parser(IObjectParser.wrapStringGetter(InfuseRegistry::get, true))
.completerOfNames(InfuseRegistry.getInfuseMap()::keySet)
.docOfType("infusion type")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,28 @@ public class Roots extends GroovyPropertyContainer {

@Override
public void initialize(GroovyContainer<?> container) {
container.objectMapper("ritual", RitualBase.class)
container.objectMapperBuilder("ritual", RitualBase.class)
.parser(IObjectParser.wrapStringGetter(RitualRegistry::getRitual))
.completerOfNames(() -> RitualRegistry.ritualRegistry.keySet())
.docOfType("ritual")
.register();
container.objectMapper("herb", Herb.class)
container.objectMapperBuilder("herb", Herb.class)
.parser(IObjectParser.wrapStringGetter(HerbRegistry::getHerbByName))
.completerOfNames(HerbRegistry.registry::keySet)
.docOfType("herb")
.register();
container.objectMapper("cost", CostType.class)
container.objectMapperBuilder("cost", CostType.class)
.parser(IObjectParser.wrapEnum(CostType.class, false))
.completerOfEnum(CostType.class, false)
.docOfType("cost")
.register();
container.objectMapper("spell", SpellBase.class)
container.objectMapperBuilder("spell", SpellBase.class)
.parser(Roots::getSpell)
.completer(SpellRegistry.spellRegistry::keySet)
.defaultValueSup(() -> Result.some(FakeSpell.INSTANCE)) // crashes otherwise
.docOfType("spell")
.register();
container.objectMapper("modifier", Modifier.class)
container.objectMapperBuilder("modifier", Modifier.class)
.parser(Roots::getModifier)
.completerOfNamed(ModifierRegistry::getModifiers, v -> v.getRegistryName().toString())
.docOfType("modifier")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public class Thaumcraft extends GroovyPropertyContainer {

@Override
public void initialize(GroovyContainer<?> container) {
container.objectMapper("aspect", AspectStack.class)
container.objectMapperBuilder("aspect", AspectStack.class)
.parser(IObjectParser.wrapStringGetter(Thaumcraft::getAspect, AspectStack::new))
.completerOfNames(thaumcraft.api.aspects.Aspect.aspects::keySet)
.docOfType("aspect stack")
.register();
container.objectMapper("crystal", ItemStack.class)
container.objectMapperBuilder("crystal", ItemStack.class)
.parser(IObjectParser.wrapStringGetter(Thaumcraft::getAspect, ThaumcraftApiHelper::makeCrystal))
.completerOfNames(thaumcraft.api.aspects.Aspect.aspects::keySet)
.defaultValue(() -> ItemStack.EMPTY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ public class TinkersConstruct extends GroovyPropertyContainer {

@Override
public void initialize(GroovyContainer<?> container) {
container.objectMapper("toolMaterial", Material.class)
container.objectMapperBuilder("toolMaterial", Material.class)
.parser(IObjectParser.wrapStringGetter(TinkerRegistryAccessor.getMaterials()::get))
.completerOfNames(TinkerRegistryAccessor.getMaterials()::keySet)
.docOfType("tool material")
.register();
container.objectMapper("toolTrait", ITrait.class)
container.objectMapperBuilder("toolTrait", ITrait.class)
.parser(IObjectParser.wrapStringGetter(TinkerRegistryAccessor.getTraits()::get))
.completerOfNamed(TinkerRegistryAccessor.getTraits()::keySet, v -> v.endsWith("_armor") ? null : v) // only suggest non armor traits
.docOfType("tool trait")
.register();
container.objectMapper("armorTrait", ITrait.class)
container.objectMapperBuilder("armorTrait", ITrait.class)
.parser(IObjectParser.wrapStringGetter(s -> TinkerRegistryAccessor.getTraits().get(s + "_armor")))
.completerOfNamed(TinkerRegistryAccessor.getTraits()::keySet,
v -> v.endsWith("_armor") ? v.substring(0, v.length() - 6) : null) // only suggest armor traits
Expand Down

0 comments on commit f5899a0

Please sign in to comment.