@Test void flagsShouldBeRemovedWhenReplaceIsFalseAndValueIsFalse() { FlagsUpdateCalculator flagsUpdateCalculator = new FlagsUpdateCalculator( new FlagsBuilder().add(Flags.Flag.DELETED, Flags.Flag.FLAGGED).add("userflag").build(), MessageManager.FlagsUpdateMode.REMOVE); assertThat(flagsUpdateCalculator.buildNewFlags(new FlagsBuilder().add(Flags.Flag.RECENT, Flags.Flag.FLAGGED).build())) .isEqualTo(new Flags(Flags.Flag.RECENT)); }
public Flags buildNewFlags(Flags oldFlags) { Flags updatedFlags = new Flags(oldFlags); switch (mode) { case REPLACE: return new Flags(providedFlags); case ADD: updatedFlags.add(providedFlags); break; case REMOVE: updatedFlags.remove(providedFlags); break; } return updatedFlags; }
FlagsUpdateCalculator { public Flags buildNewFlags(Flags oldFlags) { Flags updatedFlags = new Flags(oldFlags); switch (mode) { case REPLACE: return new Flags(providedFlags); case ADD: updatedFlags.add(providedFlags); break; case REMOVE: updatedFlags.remove(providedFlags); break; } return updatedFlags; } }
FlagsUpdateCalculator { public Flags buildNewFlags(Flags oldFlags) { Flags updatedFlags = new Flags(oldFlags); switch (mode) { case REPLACE: return new Flags(providedFlags); case ADD: updatedFlags.add(providedFlags); break; case REMOVE: updatedFlags.remove(providedFlags); break; } return updatedFlags; } FlagsUpdateCalculator(Flags providedFlags, MessageManager.FlagsUpdateMode mode); }
FlagsUpdateCalculator { public Flags buildNewFlags(Flags oldFlags) { Flags updatedFlags = new Flags(oldFlags); switch (mode) { case REPLACE: return new Flags(providedFlags); case ADD: updatedFlags.add(providedFlags); break; case REMOVE: updatedFlags.remove(providedFlags); break; } return updatedFlags; } FlagsUpdateCalculator(Flags providedFlags, MessageManager.FlagsUpdateMode mode); Flags buildNewFlags(Flags oldFlags); }
FlagsUpdateCalculator { public Flags buildNewFlags(Flags oldFlags) { Flags updatedFlags = new Flags(oldFlags); switch (mode) { case REPLACE: return new Flags(providedFlags); case ADD: updatedFlags.add(providedFlags); break; case REMOVE: updatedFlags.remove(providedFlags); break; } return updatedFlags; } FlagsUpdateCalculator(Flags providedFlags, MessageManager.FlagsUpdateMode mode); Flags buildNewFlags(Flags oldFlags);  }