Skip to content

Commit

Permalink
Merge remote-tracking branch 'Tim203/feature/interfaces'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim203 committed Feb 11, 2024
2 parents e53f8e5 + ab13924 commit 6c6f03c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import com.google.common.io.Resources;
import com.google.testing.compile.Compilation;
import com.google.testing.compile.JavaFileObjects;

import java.util.Locale;

import org.spongepowered.configurate.interfaces.Constants;

import java.io.IOException;
Expand Down Expand Up @@ -90,6 +93,7 @@ private static List<String> readOrGenerateMappings(final String sourceResourceNa
// we only support generating simple (not nested) configs,
// for complexer configs we need a mappings file
return Collections.singletonList(String.format(
Locale.ROOT,
"%s=%s",
sourceResourceName.replace('/', '.'),
targetResourceName.replace('/', '.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.spongepowered.configurate.objectmapping.meta.Processor;
import org.spongepowered.configurate.serialize.SerializationException;

import java.util.Locale;

final class InterfaceMiddleware {

private InterfaceMiddleware() {
Expand All @@ -54,6 +56,7 @@ private static Constraint.Factory<DecimalRange, Number> decimalRange() {
final double value = number.doubleValue();
if (!(data.from() >= value && data.to() <= value)) {
throw new SerializationException(String.format(
Locale.ROOT,
"'%s' is not in the allowed range of from: %s, to: %s!",
value, data.from(), data.to()
));
Expand All @@ -71,6 +74,7 @@ private static Constraint.Factory<NumericRange, Number> numericRange() {
final long value = number.longValue();
if (!(data.from() >= value && data.to() <= value)) {
throw new SerializationException(String.format(
Locale.ROOT,
"'%s' is not in the allowed range of from: %s, to: %s!",
value, data.from(), data.to()
));
Expand All @@ -88,6 +92,7 @@ private static Constraint.Factory<StringRange, String> stringRange() {
final int length = string.length();
if (!(data.from() >= length && data.to() <= length)) {
throw new SerializationException(String.format(
Locale.ROOT,
"'%s' is not in the allowed string length range of from: %s, to: %s!",
length, data.from(), data.to()
));
Expand Down

0 comments on commit 6c6f03c

Please sign in to comment.