Skip to content

Commit

Permalink
sonar warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
msbarry committed Nov 2, 2024
1 parent a956ce8 commit 4b422c1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static <I extends ScriptContext> ConfigExpressionScript<I, Object> parse(
*/
public static <I extends ScriptContext, O> ConfigExpressionScript<I, O> parse(String string,
ScriptEnvironment<I> description, Class<O> expected) {
var scriptHost = ScriptHost.newBuilder().registry(PlanetilerTypeRegistry.INSTANCE)
var scriptHost = ScriptHost.newBuilder().registry(new PlanetilerTypeRegistry())
.build();
try {
var scriptBuilder = scriptHost.buildScript(string).withLibraries(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,14 @@ public Val get(Val index) {
return Err.newErr(err, "Error getting %s", fieldName);
}
}

@Override
public final boolean equals(Object o) {
return this == o || (o instanceof GeometryVal val && val.geometry.equals(geometry));
}

@Override
public int hashCode() {
return geometry.hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@
import org.projectnessie.cel.common.types.ref.Val;

/** Registers any types that are available to CEL expressions in planetiler configs. */
public class PlanetilerTypeRegistry implements TypeRegistry {
public static final PlanetilerTypeRegistry INSTANCE = new PlanetilerTypeRegistry();
public final class PlanetilerTypeRegistry implements TypeRegistry {

@Override
public TypeRegistry copy() {
return new PlanetilerTypeRegistry();
}

@Override
public void register(Object t) {}
public void register(Object t) {
// types are defined statically
}

@Override
public void registerType(Type... types) {}
public void registerType(Type... types) {
// types are defined statically
}

@Override
public Val nativeToValue(Object value) {
Expand Down

0 comments on commit 4b422c1

Please sign in to comment.