public BooleanTerm andWith ( BooleanTerm other ) { if ( isFalse ( ) || other . isFalse ( ) ) { // anding with false, the result is false return BooleanTerm . FALSE ; } if ( other . isTrue ( ) ) { // anding with true, the result is unchanged return this ; } if ( isTrue ( ) ) { // anding with true, other is unchanged return other ; } Set < BooleanVar > result = new HashSet < BooleanVar > ( this ) ; for ( BooleanVar var : other ) { if ( result . contains ( var . negate ( ) ) ) { // If the same term has the same var with opposite states // then the resulting term is false; return BooleanTerm . FALSE ; } result . add ( var ) ; } return new BooleanTerm ( result ) ; }
Returns the logical AND of this term with the specified term .