@Test public void makeMultiple() throws Exception { factory.make(TYPE_ANY, TITLE_SMART, YEAR_DEVIATION); assertTrue(factory.make(new Type[]{TYPE_ANY}) instanceof AnyTypeComparator); }
public MovieComparator make(MovieComparator.Type type) { switch (type) { case YEAR_EQUALS: return new EqualsYearComparator(); case YEAR_DEVIATION: return new DeviationYearComparator(config); case TYPE_EQUALS: return new EqualsTypeComparator(); case TYPE_ANY: return new AnyTypeComparator(); case TITLE_EQUALS: return new EqualsTitleComparator(); case TITLE_CONTAINS: return new ContainsTitleComparator(); case TITLE_STARTS: return new StartsWithTitleComparator(); case TITLE_ENDS: return new EndsWithTitleComparator(); case TITLE_SMART: return new SmartTitleComparator(); default: throw new IllegalArgumentException("Comparator of this type not found!"); } }
MovieComparatorFactory { public MovieComparator make(MovieComparator.Type type) { switch (type) { case YEAR_EQUALS: return new EqualsYearComparator(); case YEAR_DEVIATION: return new DeviationYearComparator(config); case TYPE_EQUALS: return new EqualsTypeComparator(); case TYPE_ANY: return new AnyTypeComparator(); case TITLE_EQUALS: return new EqualsTitleComparator(); case TITLE_CONTAINS: return new ContainsTitleComparator(); case TITLE_STARTS: return new StartsWithTitleComparator(); case TITLE_ENDS: return new EndsWithTitleComparator(); case TITLE_SMART: return new SmartTitleComparator(); default: throw new IllegalArgumentException("Comparator of this type not found!"); } } }
MovieComparatorFactory { public MovieComparator make(MovieComparator.Type type) { switch (type) { case YEAR_EQUALS: return new EqualsYearComparator(); case YEAR_DEVIATION: return new DeviationYearComparator(config); case TYPE_EQUALS: return new EqualsTypeComparator(); case TYPE_ANY: return new AnyTypeComparator(); case TITLE_EQUALS: return new EqualsTitleComparator(); case TITLE_CONTAINS: return new ContainsTitleComparator(); case TITLE_STARTS: return new StartsWithTitleComparator(); case TITLE_ENDS: return new EndsWithTitleComparator(); case TITLE_SMART: return new SmartTitleComparator(); default: throw new IllegalArgumentException("Comparator of this type not found!"); } } @Inject  MovieComparatorFactory(Config config); }
MovieComparatorFactory { public MovieComparator make(MovieComparator.Type type) { switch (type) { case YEAR_EQUALS: return new EqualsYearComparator(); case YEAR_DEVIATION: return new DeviationYearComparator(config); case TYPE_EQUALS: return new EqualsTypeComparator(); case TYPE_ANY: return new AnyTypeComparator(); case TITLE_EQUALS: return new EqualsTitleComparator(); case TITLE_CONTAINS: return new ContainsTitleComparator(); case TITLE_STARTS: return new StartsWithTitleComparator(); case TITLE_ENDS: return new EndsWithTitleComparator(); case TITLE_SMART: return new SmartTitleComparator(); default: throw new IllegalArgumentException("Comparator of this type not found!"); } } @Inject  MovieComparatorFactory(Config config); MovieComparator make(MovieComparator.Type type); MovieComparator make(MovieComparator.Type... types); }
MovieComparatorFactory { public MovieComparator make(MovieComparator.Type type) { switch (type) { case YEAR_EQUALS: return new EqualsYearComparator(); case YEAR_DEVIATION: return new DeviationYearComparator(config); case TYPE_EQUALS: return new EqualsTypeComparator(); case TYPE_ANY: return new AnyTypeComparator(); case TITLE_EQUALS: return new EqualsTitleComparator(); case TITLE_CONTAINS: return new ContainsTitleComparator(); case TITLE_STARTS: return new StartsWithTitleComparator(); case TITLE_ENDS: return new EndsWithTitleComparator(); case TITLE_SMART: return new SmartTitleComparator(); default: throw new IllegalArgumentException("Comparator of this type not found!"); } } @Inject  MovieComparatorFactory(Config config); MovieComparator make(MovieComparator.Type type); MovieComparator make(MovieComparator.Type... types);  }