Skip to content

Commit

Permalink
ExpressionFunctionParameterValues subclasses toString function.name
Browse files Browse the repository at this point in the history
  • Loading branch information
mP1 committed Dec 7, 2023
1 parent 8c152af commit 04920a3
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,9 @@ public final Class<T> returnType() {
final ExpressionFunction<T, C> function;

@Override
public abstract String toString();
public final String toString() {
return this.name()
.map(FunctionExpressionName::toString)
.orElseGet(this.function::toString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,4 @@ public ExpressionFunction<T, C> filterParameterValues(final BiPredicate<Object,
* A {@link BiPredicate} that is used to filter parameter values during the prepare parameters phase before the actual wrapped {@link ExpressionFunction} is executed.
*/
private final BiPredicate<Object, C> filter;

@Override
public String toString() {
return this.function + "(" + this.filter + ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,4 @@ public ExpressionFunction<T, C> mapParameterValues(final BiFunction<List<Object>
* The {@link BiFunction} that is used to pre-process all parameter values before the wrapped {@link ExpressionFunction} is executed.
*/
private final BiFunction<List<Object>, C, List<Object>> mapper;

@Override
public String toString() {
return this.function + "(" + this.mapper + ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,4 @@ public T apply(final List<Object> parameters,
* The different/custom parameters definitions that will be used to preprocess parameter values before the wrapped {@link #function} is executed.
*/
private final List<ExpressionFunctionParameter<?>> parameters;

@Override
public String toString() {
return this.function.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,6 @@ public void testSetNameDifferent() {
this.checkEquals(NAME, function.name());
}

// toString.........................................................................................................

@Test
public void testToString() {
this.toStringAndCheck(
this.createBiFunction(),
NAME.get()
.toString()
);
}

@Override
public ExpressionFunctionCustomName<String, ExpressionEvaluationContext> createBiFunction() {
return Cast.to(ExpressionFunctionCustomName.with(wrapped(), NAME));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,6 @@ public void testFilterParameterValuesSamePredicate() {
assertSame(function, function.filterParameterValues(FILTER));
}

@Test
public void testToString() {
this.toStringAndCheck(
this.createBiFunction(),
FUNCTION + "(" + FILTER + ")"
);
}

// helpers..........................................................................................................

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,6 @@ public void testMapFunctionThenApply() {
"PARAM-1-A-namedFunction,PARAM-2-A-namedFunction,3-A-namedFunction");
}

@Test
public void testToString() {
this.toStringAndCheck(this.createBiFunction(), FUNCTION + "(" + MAPPER + ")");
}

// helpers..........................................................................................................

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,6 @@ public void testParameters() {
);
}

@Test
public void testToString() {
this.toStringAndCheck(
this.createBiFunction(),
FUNCTION.toString()
);
}

// helpers..........................................................................................................

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ public boolean isPure(final FunctionExpressionName name) {
);
}

@Test
public final void testToString() {
final F function = this.createBiFunction();

this.toStringAndCheck(
function,
function.name()
.get()
.toString()
);
}

@Override
public ExpressionEvaluationContext createContext() {
return ExpressionEvaluationContexts.fake();
Expand Down

0 comments on commit 04920a3

Please sign in to comment.