ModuleDepInfo implements Serializable { public boolean add(ModuleDepInfo other) { Boolean modified = false; if (formula.isTrue()) { return false; } if (other.formula.isTrue()) { modified = !formula.isTrue(); formula = new BooleanFormula(true); if (modified && other.comment != null && other.commentTermSize < commentTermSize) { comment = other.comment; commentTermSize = other.commentTermSize; } return modified; } modified = formula.addAll(other.formula); if (!isPluginNameDeclared && other.isPluginNameDeclared) { pluginName = other.pluginName; isPluginNameDeclared = true; modified = true; } if (other.comment != null && other.commentTermSize < commentTermSize) { comment = other.comment; commentTermSize = other.commentTermSize; } 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 testAdd() { ModuleDepInfo depInfo = new ModuleDepInfo(null, null, null); Assert.assertFalse(depInfo.add(new ModuleDepInfo(null, null, null))); Assert.assertFalse(depInfo.add(new ModuleDepInfo("has", BooleanTerm.TRUE, null))); Assert.assertFalse(depInfo.add(new ModuleDepInfo("has", new BooleanTerm("A"), null))); depInfo = new ModuleDepInfo("has", BooleanTerm.TRUE, null); Assert.assertFalse(depInfo.add(new ModuleDepInfo("has", BooleanTerm.TRUE, null))); Assert.assertFalse(depInfo.add(new ModuleDepInfo("has", new BooleanTerm("A"), null))); depInfo = new ModuleDepInfo("has", new BooleanTerm("A"), null); Assert.assertTrue(depInfo.add(new ModuleDepInfo())); Assert.assertEquals(new ModuleDepInfo(), depInfo); depInfo = new ModuleDepInfo("has", BooleanTerm.TRUE, null); Assert.assertFalse(depInfo.add(new ModuleDepInfo())); Assert.assertEquals(new ModuleDepInfo(), depInfo); depInfo = new ModuleDepInfo("has1", new BooleanTerm("A*B"), null); Assert.assertTrue(depInfo.add(new ModuleDepInfo("has2", new BooleanTerm("B*C"), null, true))); Collection<String> prefixes = depInfo.getHasPluginPrefixes(); for (String prefix : prefixes) { Assert.assertTrue(prefix.startsWith("has2!")); } depInfo.add(new ModuleDepInfo("has3", new BooleanTerm("C"), null)); for (String prefix : prefixes) { Assert.assertTrue(prefix.startsWith("has2!")); } depInfo = new ModuleDepInfo("has1", new BooleanTerm("A*B"), null, true); Assert.assertTrue(depInfo.add(new ModuleDepInfo("has2", new BooleanTerm("B*C"), null))); prefixes = depInfo.getHasPluginPrefixes(); for (String prefix : prefixes) { Assert.assertTrue(prefix.startsWith("has1!")); } depInfo = new ModuleDepInfo(null, null, null); Assert.assertFalse(depInfo.add(new ModuleDepInfo(null, null, null))); Assert.assertNull(depInfo.getComment()); Assert.assertFalse(depInfo.add(new ModuleDepInfo(null, null, "Comment"))); Assert.assertNull(depInfo.getComment()); Assert.assertFalse(depInfo.add(new ModuleDepInfo("has", new BooleanTerm("A"), "Comment 2"))); Assert.assertNull(depInfo.getComment()); depInfo = new ModuleDepInfo("has", new BooleanTerm("A*B"), "Comment 2"); Assert.assertEquals("Comment 2", depInfo.getComment()); Assert.assertTrue(depInfo.add(new ModuleDepInfo("has", new BooleanTerm("B*C"), "Comment 2.1"))); Assert.assertEquals("Comment 2", depInfo.getComment()); Assert.assertTrue(depInfo.add(new ModuleDepInfo("has", new BooleanTerm("C"), "Comment 1"))); Assert.assertEquals("Comment 1", depInfo.getComment()); Assert.assertTrue(depInfo.add(new ModuleDepInfo("has", new BooleanTerm("D"), "Comment 1.1"))); Assert.assertEquals("Comment 1", depInfo.getComment()); Assert.assertEquals( new HashSet<String>(Arrays.asList(new String[]{"has!A?B?", "has!C?", "has!D?"})), depInfo.getHasPluginPrefixes() ); Assert.assertTrue(depInfo.add(new ModuleDepInfo("has", null, "Comment"))); Assert.assertEquals("Comment", depInfo.getComment()); Assert.assertNull(depInfo.getHasPluginPrefixes()); }