Skip to content

Commit

Permalink
Lower visibility of ExpressionParser#getDefaultEnv, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
FourteenBrush committed Sep 8, 2023
1 parent ebb2b3b commit 6e1094f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ ExecutionEnv env = new ExecutionEnv();
env.insertFunction("input", in::nextDouble);

env.insertFunction("isleapyear", 1, ctx -> {
// need a FunctionContext param in order to get an int
int year = ctx.getInt(0);
// copied from java.time.Year.isLeap
// you need a FunctionContext parameter to force the input to be an int
// as all parameters are doubles implicitly
int year = ctx.getInt(0);
return Utility.boolToDouble(java.time.Year.isLeap(year));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
import java.util.function.DoubleUnaryOperator;
import java.util.function.ToDoubleFunction;

@SuppressWarnings("unused")
public class ExpressionParser {
private static ExecutionEnv DEFAULT_ENV;

private ExpressionParser() {}

/**
* @see ExpressionParser#parse(String, ExecutionEnv)
*/
public static double parse(String input) {
return parse(input, getDefaultEnv());
}
Expand Down Expand Up @@ -89,7 +93,7 @@ public static void insertSymbol(Symbol symbol) {
getDefaultEnv().insertSymbol(symbol);
}

public static ExecutionEnv getDefaultEnv() {
private static ExecutionEnv getDefaultEnv() {
if (DEFAULT_ENV == null) {
DEFAULT_ENV = new ExecutionEnv();
}
Expand Down

0 comments on commit 6e1094f

Please sign in to comment.