BooleanTerm extends HashSet<BooleanVar> { @Override public String toString() { if (isTrue()) { return "[TRUE]"; } if (isFalse()) { return "[FALSE]"; } StringBuffer sb = new StringBuffer(); if (size() > 1) sb.append("("); int i = 0; for (BooleanVar var : new TreeSet<BooleanVar>(this)) { sb.append(i++ > 0 ? "*" : "").append(var); } if (size() > 1) sb.append(")"); return sb.toString(); } private  BooleanTerm();  BooleanTerm(BooleanVar var);  BooleanTerm(Set<BooleanVar> term);  BooleanTerm(String str); boolean isTrue(); boolean isFalse(); BooleanTerm resolveWith(Features features); BooleanTerm resolveWith(Features features, boolean coerceUndefinedToFalse); BooleanTerm andWith(BooleanTerm other); @Override String toString(); @Override boolean add(BooleanVar object); @Override void clear(); @Override boolean remove(Object object); @Override boolean removeAll(Collection<?> collection); @Override boolean addAll(Collection<? extends BooleanVar> collection); @Override boolean retainAll(Collection<?> collection); @Override int hashCode(); @Override boolean equals(Object other); static final BooleanTerm TRUE; static final BooleanTerm FALSE; }
@Test public void testToString() { assertEquals("[TRUE]", BooleanTerm.TRUE.toString()); assertEquals("[FALSE]", BooleanTerm.FALSE.toString()); assertEquals("A", new BooleanTerm("A").toString()); assertEquals("(A*B)", new BooleanTerm("A*B").toString()); assertEquals("(!A*B)", new BooleanTerm("B*!A").toString()); }