@Test public void testIsEmptyNull() { assertThatThrownBy(() -> IterableLike.isEmpty(null)).isInstanceOf(IllegalArgumentException.class); } }
@Test public void testIsEmptyList() { final List<String> in = new ArrayList<String>(); in.add("1"); in.add("2"); in.add("3"); assertThat(IterableLike.isEmpty(in)).isFalse(); }
@Test public void testIsEmptyEmptyList() { assertThat(IterableLike.isEmpty(new ArrayList<String>())).isTrue(); }
@Test public void testIsEmptyObjectArray() { assertThat(IterableLike.isEmpty(new Object[]{"1", "2", "3"})).isFalse(); }
@Test public void testIsEmptyEmptyPrimitiveArray() { assertThat(IterableLike.isEmpty(new int[]{})).isTrue(); }
@Test public void testIsEmptyPrimitive() { assertThatThrownBy(() -> IterableLike.isEmpty(5)).isInstanceOf(IllegalArgumentException.class); }
@Test public void testIsEmptyPrimitiveArray() { assertThat(IterableLike.isEmpty(new int[]{1, 2, 3})).isFalse(); }
@Test public void testIsEmptyEmptyObjectArray() { assertThat(IterableLike.isEmpty(new Object[]{})).isTrue(); }
@Test public void testIsEmptyObject() { assertThatThrownBy(() -> IterableLike.isEmpty(new Object())).isInstanceOf(IllegalArgumentException.class); }
@Override public SqlStatementParameterCustomizer createForParameter(Annotation annotation, Class<?> sqlObjectType, Method method, Parameter param, int index, Type type) { final BindList bindList = (BindList) annotation; final String name = ParameterUtil.findParameterName(bindList.value(), param) .orElseThrow(() -> new UnsupportedOperationException("A @BindList parameter was not given a name, " + "and parameter name data is not present in the class file, for: " + param.getDeclaringExecutable() + "::" + param)); return (stmt, arg) -> { if (arg == null || IterableLike.isEmpty(arg)) { bindList.onEmpty().define(stmt, name); } else { stmt.bindList(name, IterableLike.toList(arg)); } }; } }