Skip to content

Commit

Permalink
Upgrade eclipse formatter (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
msbarry authored Oct 26, 2023
1 parent b108f88 commit a0cd4fa
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private <O> ConfigExpression<I, O> parse(Object object, Class<O> output) {
return cast(signature(output), child, dataType);
} else {
var keys = map.keySet();
if (keys.equals(Set.of("coalesce")) && map.get("coalesce")instanceof Collection<?> cases) {
if (keys.equals(Set.of("coalesce")) && map.get("coalesce") instanceof Collection<?> cases) {
return coalesce(cases.stream().map(item -> parse(item, output)).toList());
} else if (keys.equals(Set.of("match"))) {
return parseMatch(map.get("match"), true, output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private static String doubleToString(Double d) {
return d % 1 == 0 ? Long.toString(d.longValue()) : d.toString();
}

private record Converter<I, O> (Class<I> in, Class<O> out, Function<I, O> fn) implements Function<Object, O> {
private record Converter<I, O>(Class<I> in, Class<O> out, Function<I, O> fn) implements Function<Object, O> {
@Override
public O apply(Object in) {
@SuppressWarnings("unchecked") I converted = (I) in;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @param <T> Type of the expression context
*/
public record BooleanExpressionScript<T extends ScriptContext> (
public record BooleanExpressionScript<T extends ScriptContext>(
String expressionText,
ConfigExpressionScript<T, Boolean> expression,
Class<T> inputClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static <I extends ScriptContext, O> Signature<I, O> signature(ScriptEnvironment<
}

/** An expression that always returns {@code value}. */
record Const<I extends ScriptContext, O> (O value) implements ConfigExpression<I, O> {
record Const<I extends ScriptContext, O>(O value) implements ConfigExpression<I, O> {

@Override
public O apply(I i) {
Expand All @@ -79,7 +79,7 @@ public O apply(I i) {
}

/** An expression that returns the value associated with the first matching boolean expression. */
record Match<I extends ScriptContext, O> (
record Match<I extends ScriptContext, O>(
Signature<I, O> signature,
MultiExpression<ConfigExpression<I, O>> multiExpression,
ConfigExpression<I, O> fallback,
Expand Down Expand Up @@ -146,7 +146,7 @@ public Match<I, O> withDefaultValue(ConfigExpression<I, O> newFallback) {
}

/** An expression that returns the first non-null result of evaluating each child expression. */
record Coalesce<I extends ScriptContext, O> (List<? extends ConfigExpression<I, O>> children)
record Coalesce<I extends ScriptContext, O>(List<? extends ConfigExpression<I, O>> children)
implements ConfigExpression<I, O> {

@Override
Expand Down Expand Up @@ -184,7 +184,7 @@ yield coalesce(result.stream().map(d -> {
}

/** An expression that returns the value associated a given variable name at runtime. */
record Variable<I extends ScriptContext, O> (
record Variable<I extends ScriptContext, O>(
Signature<I, O> signature,
String name
) implements ConfigExpression<I, O> {
Expand All @@ -202,7 +202,7 @@ public O apply(I i) {
}

/** An expression that returns the value associated a given tag of the input feature at runtime. */
record GetTag<I extends ScriptContext, O> (
record GetTag<I extends ScriptContext, O>(
Signature<I, O> signature,
ConfigExpression<I, String> tag
) implements ConfigExpression<I, O> {
Expand All @@ -219,7 +219,7 @@ public ConfigExpression<I, O> simplifyOnce() {
}

/** An expression that returns the value associated a given argument at runtime. */
record GetArg<I extends ScriptContext, O> (
record GetArg<I extends ScriptContext, O>(
Signature<I, O> signature,
ConfigExpression<I, String> arg
) implements ConfigExpression<I, O> {
Expand All @@ -242,7 +242,7 @@ public ConfigExpression<I, O> simplifyOnce() {
}

/** An expression that converts the input to a desired output {@link DataType} at runtime. */
record Cast<I extends ScriptContext, O> (
record Cast<I extends ScriptContext, O>(
Signature<I, O> signature,
ConfigExpression<I, ?> input,
DataType output
Expand All @@ -268,7 +268,7 @@ public ConfigExpression<I, O> simplifyOnce() {
}
}

record Signature<I extends ScriptContext, O> (ScriptEnvironment<I> in, Class<O> out) {
record Signature<I extends ScriptContext, O>(ScriptEnvironment<I> in, Class<O> out) {

public <O2> Signature<I, O2> withOutput(Class<O2> newOut) {
return new Signature<>(in, newOut);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @param clazz Class of the input context type
* @param <T> The runtime expression context type
*/
public record ScriptEnvironment<T extends ScriptContext> (List<Decl> declarations, Class<T> clazz, Contexts.Root root) {
public record ScriptEnvironment<T extends ScriptContext>(List<Decl> declarations, Class<T> clazz, Contexts.Root root) {
private static <T> List<T> concat(List<T> a, List<T> b) {
return Stream.concat(a.stream(), b.stream()).toList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public List<OsmRelationInfo> preprocessOsmRelation(OsmElement.Relation relation)
relation.getString("route"),
// except map network abbreviation to a human-readable value
switch (relation.getString("network", "")) {
case "icn" -> "international";
case "ncn" -> "national";
case "rcn" -> "regional";
case "lcn" -> "local";
default -> "other";
case "icn" -> "international";
case "ncn" -> "national";
case "rcn" -> "regional";
case "lcn" -> "local";
default -> "other";
}
));
}
Expand Down
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,16 @@
<version>2.40.0</version>
<configuration>
<java>
<includes>
<include>*.java</include>
</includes>
<excludes>
<exclude>planetiler-openmaptiles/**/*.java</exclude>
</excludes>
<importOrder/>
<removeUnusedImports/>
<eclipse>
<version>4.21.0</version>
<version>4.29</version>
<!--suppress UnresolvedMavenProperty -->
<file>${maven.multiModuleProjectDirectory}/eclipse-formatter.xml</file>
</eclipse>
Expand Down Expand Up @@ -256,7 +262,7 @@
</configuration>
</plugin>
</plugins>

<pluginManagement>
<plugins>
<plugin>
Expand Down

0 comments on commit a0cd4fa

Please sign in to comment.