@Test public void doSwitchWithoutWrappers() { TripleArgumentTypeSwitch<String, String, String, String> s = new TripleArgumentTypeSwitch<String, String, String, String>() { @Override protected String caseBoolean(String value1, String value2, String value3) { return "bool" + value1 + value2 + value3; } @Override protected String caseByte(String value1, String value2, String value3) { return "byte" + value1 + value2 + value3; } @Override protected String caseCharacter(String value1, String value2, String value3) { return "c" + value1 + value2 + value3; } @Override protected String caseShort(String value1, String value2, String value3) { return "s" + value1 + value2 + value3; } @Override protected String caseInteger(String value1, String value2, String value3) { return "i" + value1 + value2 + value3; } @Override protected String caseLong(String value1, String value2, String value3) { return "l" + value1 + value2 + value3; } @Override protected String caseFloat(String value1, String value2, String value3) { return "f" + value1 + value2 + value3; } @Override protected String caseDouble(String value1, String value2, String value3) { return "d" + value1 + value2 + value3; } @Override protected String caseLocalDateTime(String value1, String value2, String value3) { return "ldt" + value1 + value2 + value3; } @Override protected String caseByteArray(String value1, String value2, String value3) { return "ba" + value1 + value2 + value3; } @Override protected String defaultCase(String value1, String value2, String value3) { return "def" + value1 + value2 + value3; } }; assertEquals("boolv1v2v3", s.doSwitch(boolean.class, "v1", "v2", "v3")); assertEquals("boolv1v2v3", s.doSwitch(Boolean.class, "v1", "v2", "v3")); assertEquals("bytev1v2v3", s.doSwitch(byte.class, "v1", "v2", "v3")); assertEquals("bytev1v2v3", s.doSwitch(Byte.class, "v1", "v2", "v3")); assertEquals("cv1v2v3", s.doSwitch(char.class, "v1", "v2", "v3")); assertEquals("cv1v2v3", s.doSwitch(Character.class, "v1", "v2", "v3")); assertEquals("sv1v2v3", s.doSwitch(short.class, "v1", "v2", "v3")); assertEquals("sv1v2v3", s.doSwitch(Short.class, "v1", "v2", "v3")); assertEquals("iv1v2v3", s.doSwitch(int.class, "v1", "v2", "v3")); assertEquals("iv1v2v3", s.doSwitch(Integer.class, "v1", "v2", "v3")); assertEquals("lv1v2v3", s.doSwitch(long.class, "v1", "v2", "v3")); assertEquals("lv1v2v3", s.doSwitch(Long.class, "v1", "v2", "v3")); assertEquals("fv1v2v3", s.doSwitch(float.class, "v1", "v2", "v3")); assertEquals("fv1v2v3", s.doSwitch(Float.class, "v1", "v2", "v3")); assertEquals("dv1v2v3", s.doSwitch(double.class, "v1", "v2", "v3")); assertEquals("dv1v2v3", s.doSwitch(Double.class, "v1", "v2", "v3")); assertEquals("ldtv1v2v3", s.doSwitch(LocalDateTime.class, "v1", "v2", "v3")); assertEquals("bav1v2v3", s.doSwitch(byte[].class, "v1", "v2", "v3")); assertEquals("defv1v2v3", s.doSwitch(String.class, "v1", "v2", "v3")); }
public final R doSwitch(Class<?> type, T1 value1, T2 value2, T3 value3) { Func3<T1, T2, T3, R> typeCase = cases.get(type); if (typeCase != null) { return typeCase.call(value1, value2, value3); } else { return defaultCase(value1, value2, value3); } }
TripleArgumentTypeSwitch { public final R doSwitch(Class<?> type, T1 value1, T2 value2, T3 value3) { Func3<T1, T2, T3, R> typeCase = cases.get(type); if (typeCase != null) { return typeCase.call(value1, value2, value3); } else { return defaultCase(value1, value2, value3); } } }
TripleArgumentTypeSwitch { public final R doSwitch(Class<?> type, T1 value1, T2 value2, T3 value3) { Func3<T1, T2, T3, R> typeCase = cases.get(type); if (typeCase != null) { return typeCase.call(value1, value2, value3); } else { return defaultCase(value1, value2, value3); } } TripleArgumentTypeSwitch(); }
TripleArgumentTypeSwitch { public final R doSwitch(Class<?> type, T1 value1, T2 value2, T3 value3) { Func3<T1, T2, T3, R> typeCase = cases.get(type); if (typeCase != null) { return typeCase.call(value1, value2, value3); } else { return defaultCase(value1, value2, value3); } } TripleArgumentTypeSwitch(); final R doSwitch(Class<?> type, T1 value1, T2 value2, T3 value3); }
TripleArgumentTypeSwitch { public final R doSwitch(Class<?> type, T1 value1, T2 value2, T3 value3) { Func3<T1, T2, T3, R> typeCase = cases.get(type); if (typeCase != null) { return typeCase.call(value1, value2, value3); } else { return defaultCase(value1, value2, value3); } } TripleArgumentTypeSwitch(); final R doSwitch(Class<?> type, T1 value1, T2 value2, T3 value3);  }