Skip to content

Commit

Permalink
some minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
elisherer committed Jul 26, 2024
1 parent b3a0c0a commit 99f5308
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

@ArgumentType(value = "default", type = ArgType.BigDecimal, position = 0, defaultBigDecimal = 0,
description = "The default value to use for empty values")
@ArgumentType(value = "by", type = ArgType.Transformer, position = 1, required = false,
@ArgumentType(value = "by", type = ArgType.Transformer, position = 1,
defaultString = "##current",
description = "A transformer to extract a property to sum by (using ##current to refer to the current item)")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

public abstract class FunctionContext<JE, JA extends Iterable<JE>, JO extends JE> {

protected final String CONTEXT_KEY = "context";
protected final String DOUBLE_HASH_CURRENT = "##current";
protected final String DOUBLE_HASH_INDEX = "##index";
protected final String DOLLAR = "$";
Expand Down Expand Up @@ -53,8 +54,8 @@ public FunctionContext(JsonAdapter<JE,JA,JO> jsonAdapter, String alias, Transfor
}

private ParameterResolver recalcResolver(JO definition, ParameterResolver resolver, JsonTransformerFunction<JE> extractor) {
if (adapter.jObject.has(definition, "context")) {
var contextElement = adapter.jObject.get(definition, "context");
if (adapter.jObject.has(definition, CONTEXT_KEY)) {
var contextElement = adapter.jObject.get(definition, CONTEXT_KEY);
if (adapter.jObject.is(contextElement)) {
var ctx = adapter.jObject.convert(contextElement);
var addCtx = adapter.jObject.entrySet(ctx).stream().collect(
Expand All @@ -66,7 +67,7 @@ private ParameterResolver recalcResolver(JO definition, ParameterResolver resolv
return name -> {
for (var key : addCtx.keySet()) {
if (pathOfVar(key, name)) {
return addCtx.get(key).read("$" + name.substring(key.length()));
return addCtx.get(key).read(DOLLAR + name.substring(key.length()));
}
}
return resolver.get(name);
Expand Down

0 comments on commit 99f5308

Please sign in to comment.