ModuleDepInfo implements Serializable { public boolean subtract(ModuleDepInfo toSub) { boolean modified = false; if (toSub.formula.isTrue()) { modified = !formula.isFalse(); formula = new BooleanFormula(false); } else if (formula.isTrue()) { return false; } else { Set<BooleanTerm> termsToRemove = new HashSet<BooleanTerm>(); for (BooleanTerm t1 : formula) { for (BooleanTerm t2 : toSub.formula) { if (t1.containsAll(t2)) { termsToRemove.add(t1); } } } modified |= formula.removeTerms(termsToRemove); if (formula.size() == 0) { formula = new BooleanFormula(false); } } if (formula.isFalse()) { comment = null; commentTermSize = 0; } return modified; } ModuleDepInfo();  ModuleDepInfo(ModuleDepInfo other);  ModuleDepInfo(ModuleDepInfo other, String comment);  ModuleDepInfo(String pluginName, BooleanTerm term, String comment);  ModuleDepInfo(String pluginName, BooleanTerm term, String comment, boolean isPluginNameDeclared); Collection<String> getHasPluginPrefixes(); Collection<String> getHasPluginPrefixes(Map<?, ?> formulaCache); Boolean getIncludeStatus(); boolean containsTerm(BooleanTerm term); ModuleDepInfo andWith(ModuleDepInfo other); String getComment(); boolean add(ModuleDepInfo other); boolean subtract(ModuleDepInfo toSub); void resolveWith(Features features); void resolveWith(Features features, boolean coerceUndefinedToFalse); ModuleDepInfo simplify(Map<?, ?> formulaCache); @Override String toString(); @Override boolean equals(Object otherObj); @Override int hashCode();  }
@Test public void testSubtract() { ModuleDepInfo depInfo = new ModuleDepInfo("has", new BooleanTerm("A*B"), null); Assert.assertTrue(depInfo.add(new ModuleDepInfo("has", new BooleanTerm("B*C"), null))); Assert.assertTrue(depInfo.add(new ModuleDepInfo("has", new BooleanTerm("C*D"), null))); Assert.assertTrue(depInfo.subtract(new ModuleDepInfo("has", new BooleanTerm("B*C"), null))); Assert.assertEquals( new HashSet<String>(Arrays.asList(new String[]{"has!A?B?", "has!C?D?"})), depInfo.getHasPluginPrefixes() ); Assert.assertTrue(depInfo.subtract(new ModuleDepInfo("has", new BooleanTerm("A"), null))); Assert.assertEquals( new HashSet<String>(Arrays.asList(new String[]{"has!C?D?"})), depInfo.getHasPluginPrefixes() ); Assert.assertTrue(depInfo.subtract(new ModuleDepInfo("has", new BooleanTerm("C*D"), null))); Assert.assertEquals(0, depInfo.getHasPluginPrefixes().size()); depInfo = new ModuleDepInfo("has", new BooleanTerm("B*C"), null); Assert.assertTrue(depInfo.add(new ModuleDepInfo("has", new BooleanTerm("C*D"), null))); Assert.assertTrue(depInfo.subtract(new ModuleDepInfo("has", new BooleanTerm("C"), null))); Assert.assertEquals(0, depInfo.getHasPluginPrefixes().size()); depInfo = new ModuleDepInfo("has", null, null); Assert.assertFalse(depInfo.subtract(new ModuleDepInfo("has", new BooleanTerm("B*C"), null))); Assert.assertTrue(depInfo.subtract(new ModuleDepInfo(null, null, null))); Assert.assertEquals(0, depInfo.getHasPluginPrefixes().size()); depInfo = new ModuleDepInfo("has", new BooleanTerm("A*B"), null); Assert.assertTrue(depInfo.subtract(new ModuleDepInfo(null, null, null))); Assert.assertEquals(0, depInfo.getHasPluginPrefixes().size()); depInfo = new ModuleDepInfo("has", new BooleanTerm("A"), "Comment A"); Assert.assertTrue(depInfo.add(new ModuleDepInfo("has", new BooleanTerm("B"), "Comment B"))); Assert.assertTrue(depInfo.add(new ModuleDepInfo("has", new BooleanTerm("C"), "Comment C"))); Assert.assertEquals("Comment A", depInfo.getComment()); Assert.assertTrue(depInfo.subtract(new ModuleDepInfo("has", new BooleanTerm("A"), null))); Assert.assertEquals("Comment A", depInfo.getComment()); Assert.assertTrue(depInfo.subtract(new ModuleDepInfo("has", new BooleanTerm("C"), null))); Assert.assertEquals("Comment A", depInfo.getComment()); Assert.assertTrue(depInfo.subtract(new ModuleDepInfo("has", new BooleanTerm("B"), null))); Assert.assertNull(depInfo.getComment()); }