@Test void orElse() { List<String> param = Arrays.asList("String", "Two"); List<Integer> testing = new ArrayList<>(); CaseMatch.match(param) .when(Map.class, c -> testing.add(1)) .when(Set.class, () -> testing.add(2)) .orElse(() -> testing.add(-1)); Assertions.assertTrue(testing.size() ==1); Assertions.assertTrue(testing.get(0) == -1); }
public <T> CaseMatch orElse(Runnable statement) { Objects.requireNonNull(statement); if (!executed) { statement.run(); this.executed = true; } return this; }
CaseMatch extends AbstractMatch { public <T> CaseMatch orElse(Runnable statement) { Objects.requireNonNull(statement); if (!executed) { statement.run(); this.executed = true; } return this; } }
CaseMatch extends AbstractMatch { public <T> CaseMatch orElse(Runnable statement) { Objects.requireNonNull(statement); if (!executed) { statement.run(); this.executed = true; } return this; } private  CaseMatch(Object o); }
CaseMatch extends AbstractMatch { public <T> CaseMatch orElse(Runnable statement) { Objects.requireNonNull(statement); if (!executed) { statement.run(); this.executed = true; } return this; } private  CaseMatch(Object o); CaseMatch when(Class<T> type, Runnable statement); CaseMatch when(Class<T> type, Consumer<T> statement); CaseMatch orElse(Runnable statement); static CaseMatch match(Object o); }
CaseMatch extends AbstractMatch { public <T> CaseMatch orElse(Runnable statement) { Objects.requireNonNull(statement); if (!executed) { statement.run(); this.executed = true; } return this; } private  CaseMatch(Object o); CaseMatch when(Class<T> type, Runnable statement); CaseMatch when(Class<T> type, Consumer<T> statement); CaseMatch orElse(Runnable statement); static CaseMatch match(Object o);  }