Skip to content

ZhaoWengang/BooleanEvaluate-Apex

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Apex code for boolean expression evaluation

Usage:

This class has 2 different constructors with 2 methods each.

First:

public BooleanEvaluate(String expression, Boolean[] values){ ... }

So, the parameter 'expression' must be using ordinal numbers related to the parameter 'values' (Examples below)

Second:

public BooleanEvaluate(String expression, String[] arguments){ ... }

So, the parameter 'expression' must be using arument numbers (preffixed with $) related to the parameter 'arguments' (Examples below)

EXAMPLES

First:

List<Boolean> values = new List<Boolean>{
true, false, true, true, false, true, true, true
};

BooleanEvaluate boolEval = new BooleanEvaluate('1 && ( ( 2 || 3 ) && 6 ) && ( 4 && 5 || ( 7 && 8 ) )', values);
boolEval.evaluate();

Second:

List<Boolean> values = new List<Boolean>{
true, false, true, true, false, true, true, true
};

String[] strValues = new String[values.size()];
for(Boolean b : values)
    strValues.add(String.valueOf(b));

BooleanEvaluate stringEval = new BooleanEvaluate('$1 && ( ( $2 || $3 ) && $6 ) && ( $4 && $5 || ( $7 && $8 ) )', strValues);
stringEval.evaluate();

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Apex 100.0%