Skip to content

Commit 83c1acf

Browse files
committed
Renamed Function interface to avoid name clash with java.util.function.Function.
1 parent 33f365e commit 83c1acf

File tree

9 files changed

+23
-23
lines changed

9 files changed

+23
-23
lines changed

json-path/src/main/java/com/jayway/jsonpath/internal/function/Length.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* Created by mattg on 6/26/15.
1010
*/
11-
public class Length implements Function {
11+
public class Length implements PathFunction {
1212

1313
@Override
1414
public Object invoke(String currentPath, PathRef parent, Object model, EvaluationContext ctx) {

json-path/src/main/java/com/jayway/jsonpath/internal/function/PassthruFunction.java renamed to json-path/src/main/java/com/jayway/jsonpath/internal/function/PassthruPathFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* Created by mattg on 6/26/15.
1010
*/
11-
public class PassthruFunction implements Function {
11+
public class PassthruPathFunction implements PathFunction {
1212

1313
@Override
1414
public Object invoke(String currentPath, PathRef parent, Object model, EvaluationContext ctx) {

json-path/src/main/java/com/jayway/jsonpath/internal/function/Function.java renamed to json-path/src/main/java/com/jayway/jsonpath/internal/function/PathFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
* Created by matt@mjgreenwood.net on 6/26/15.
1313
*/
14-
public interface Function {
14+
public interface PathFunction {
1515

1616
/**
1717
* Invoke the function and output a JSON object (or scalar) value which will be the result of executing the path

json-path/src/main/java/com/jayway/jsonpath/internal/function/FunctionFactory.java renamed to json-path/src/main/java/com/jayway/jsonpath/internal/function/PathFunctionFactory.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* Created by mattg on 6/27/15.
2222
*/
23-
public class FunctionFactory {
23+
public class PathFunctionFactory {
2424

2525
public static final Map<String, Class> FUNCTIONS;
2626

@@ -46,7 +46,7 @@ public class FunctionFactory {
4646
* implementation based on the name using the internal FUNCTION map
4747
*
4848
* @see #FUNCTIONS
49-
* @see Function
49+
* @see PathFunction
5050
*
5151
* @param name
5252
* The name of the function
@@ -56,12 +56,12 @@ public class FunctionFactory {
5656
*
5757
* @throws InvalidPathException
5858
*/
59-
public static Function newFunction(String name) throws InvalidPathException {
60-
Function result = new PassthruFunction();
59+
public static PathFunction newFunction(String name) throws InvalidPathException {
60+
PathFunction result = new PassthruPathFunction();
6161

62-
if (null != name && FUNCTIONS.containsKey(name) && Function.class.isAssignableFrom(FUNCTIONS.get(name))) {
62+
if (null != name && FUNCTIONS.containsKey(name) && PathFunction.class.isAssignableFrom(FUNCTIONS.get(name))) {
6363
try {
64-
result = (Function)FUNCTIONS.get(name).newInstance();
64+
result = (PathFunction)FUNCTIONS.get(name).newInstance();
6565
} catch (InstantiationException e) {
6666
throw new InvalidPathException("Function of name: " + name + " cannot be created", e);
6767
} catch (IllegalAccessException e) {

json-path/src/main/java/com/jayway/jsonpath/internal/function/numeric/AbstractAggregation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.jayway.jsonpath.internal.EvaluationContext;
44
import com.jayway.jsonpath.internal.PathRef;
5-
import com.jayway.jsonpath.internal.function.Function;
5+
import com.jayway.jsonpath.internal.function.PathFunction;
66

77
/**
88
* Defines the pattern for processing numerical values via an abstract implementation that iterates over the collection
@@ -11,7 +11,7 @@
1111
*
1212
* Created by mattg on 6/26/15.
1313
*/
14-
public abstract class AbstractAggregation implements Function {
14+
public abstract class AbstractAggregation implements PathFunction {
1515

1616
/**
1717
* Defines the next value in the array to the mathmatical function

json-path/src/main/java/com/jayway/jsonpath/internal/token/FunctionPathToken.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.jayway.jsonpath.internal.token;
22

33
import com.jayway.jsonpath.internal.PathRef;
4-
import com.jayway.jsonpath.internal.function.Function;
5-
import com.jayway.jsonpath.internal.function.FunctionFactory;
4+
import com.jayway.jsonpath.internal.function.PathFunction;
5+
import com.jayway.jsonpath.internal.function.PathFunctionFactory;
66

77
/**
88
* Token representing a Function call to one of the functions produced via the FunctionFactory
99
*
10-
* @see FunctionFactory
10+
* @see PathFunctionFactory
1111
*
1212
* Created by mattg on 6/27/15.
1313
*/
@@ -27,8 +27,8 @@ public FunctionPathToken(String pathFragment) {
2727

2828
@Override
2929
public void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) {
30-
Function function = FunctionFactory.newFunction(functionName);
31-
Object result = function.invoke(currentPath, parent, model, ctx);
30+
PathFunction pathFunction = PathFunctionFactory.newFunction(functionName);
31+
Object result = pathFunction.invoke(currentPath, parent, model, ctx);
3232
ctx.addResult(currentPath, parent, result);
3333
}
3434

json-path/src/main/java/com/jayway/jsonpath/internal/token/PathToken.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import com.jayway.jsonpath.PathNotFoundException;
1919
import com.jayway.jsonpath.internal.PathRef;
2020
import com.jayway.jsonpath.internal.Utils;
21-
import com.jayway.jsonpath.internal.function.Function;
21+
import com.jayway.jsonpath.internal.function.PathFunction;
2222
import com.jayway.jsonpath.spi.json.JsonProvider;
2323

2424
import java.util.List;
@@ -204,8 +204,8 @@ public boolean equals(Object obj) {
204204
return super.equals(obj);
205205
}
206206

207-
public void invoke(Function function, String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) {
208-
ctx.addResult(currentPath, parent, function.invoke(currentPath, parent, model, ctx));
207+
public void invoke(PathFunction pathFunction, String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) {
208+
ctx.addResult(currentPath, parent, pathFunction.invoke(currentPath, parent, model, ctx));
209209
}
210210

211211
public abstract void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx);

json-path/src/test/java/com/jayway/jsonpath/functions/JSONEntityFunctionTest.java renamed to json-path/src/test/java/com/jayway/jsonpath/functions/JSONEntityPathFunctionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
* Created by mattg on 6/27/15.
1313
*/
14-
public class JSONEntityFunctionTest extends BaseFunctionTest {
14+
public class JSONEntityPathFunctionTest extends BaseFunctionTest {
1515

1616

1717
private static final String BATCH_JSON = "{\n" +

json-path/src/test/java/com/jayway/jsonpath/functions/NumericFunctionTest.java renamed to json-path/src/test/java/com/jayway/jsonpath/functions/NumericPathFunctionTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
* Created by mattg on 6/26/15.
2424
*/
2525
@RunWith(Parameterized.class)
26-
public class NumericFunctionTest extends BaseFunctionTest {
26+
public class NumericPathFunctionTest extends BaseFunctionTest {
2727

28-
private static final Logger logger = LoggerFactory.getLogger(NumericFunctionTest.class);
28+
private static final Logger logger = LoggerFactory.getLogger(NumericPathFunctionTest.class);
2929

3030
private Configuration conf = Configurations.GSON_CONFIGURATION;
3131

32-
public NumericFunctionTest(Configuration conf) {
32+
public NumericPathFunctionTest(Configuration conf) {
3333
logger.debug("Testing with configuration {}", conf.getClass().getName());
3434
this.conf = conf;
3535
}

0 commit comments

Comments
 (0)