java - Is there a data structure for storing boolean expressions? -


i need store boolean expressions this:

x1 , x2 , x3 or (x4 , x5) , (not x6) 

each x variable boolean expression == or != values. problem store nested and , or clauses (inside and/or inside each other) , wrap them not. wrapping depth can deep.

does java sdk have data structure these expressions?

in java 8 functional interface predicate<t> way go.

here java docs.

and here various examples.

so in use case follows:

public static predicate<integer> equals(integer compare) {     return -> i.equals(compare); }  public static predicate<integer> complex() {     return equals(1).and(equals(2)).and(equals(3)).or(equals(4).and(equals(5))).and(equals(6).negate()); } 

remember — java 8 onwards!


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -