/** * 多个值的and */ public static boolean and(final boolean... array) { return BooleanUtils.and(array); }
return and(primitive) ? Boolean.TRUE : Boolean.FALSE; } catch (final NullPointerException ex) { throw new IllegalArgumentException("The array must not contain any null elements");
@Test(expected = IllegalArgumentException.class) public void testAnd_object_emptyInput() { BooleanUtils.and(new Boolean[] {}); }
@Test(expected = IllegalArgumentException.class) public void testAnd_primitive_emptyInput() { BooleanUtils.and(new boolean[] {}); }
@Test(expected = IllegalArgumentException.class) public void testAnd_primitive_nullInput() { BooleanUtils.and((boolean[]) null); }
@Test(expected = IllegalArgumentException.class) public void testAnd_object_nullInput() { BooleanUtils.and((Boolean[]) null); }
@Test(expected = IllegalArgumentException.class) public void testAnd_object_nullElementInput() { BooleanUtils.and(new Boolean[] {null}); }
@Test public void testAnd_primitive_validInput_2items() { assertTrue( "False result for (true, true)", BooleanUtils.and(new boolean[] { true, true })); assertTrue( "True result for (false, false)", ! BooleanUtils.and(new boolean[] { false, false })); assertTrue( "True result for (true, false)", ! BooleanUtils.and(new boolean[] { true, false })); assertTrue( "True result for (false, true)", ! BooleanUtils.and(new boolean[] { false, true })); }
@Test public void testAnd_object_validInput_2items() { assertTrue( "False result for (true, true)", BooleanUtils .and(new Boolean[] { Boolean.TRUE, Boolean.TRUE }) .booleanValue()); assertTrue( "True result for (false, false)", ! BooleanUtils .and(new Boolean[] { Boolean.FALSE, Boolean.FALSE }) .booleanValue()); assertTrue( "True result for (true, false)", ! BooleanUtils .and(new Boolean[] { Boolean.TRUE, Boolean.FALSE }) .booleanValue()); assertTrue( "True result for (false, true)", ! BooleanUtils .and(new Boolean[] { Boolean.FALSE, Boolean.TRUE }) .booleanValue()); }
@Test public void testAnd_primitive_validInput_3items() { assertTrue( "True result for (false, false, true)", ! BooleanUtils.and(new boolean[] { false, false, true })); assertTrue( "True result for (false, true, false)", ! BooleanUtils.and(new boolean[] { false, true, false })); assertTrue( "True result for (true, false, false)", ! BooleanUtils.and(new boolean[] { true, false, false })); assertTrue( "False result for (true, true, true)", BooleanUtils.and(new boolean[] { true, true, true })); assertTrue( "True result for (false, false)", ! BooleanUtils.and(new boolean[] { false, false, false })); assertTrue( "True result for (true, true, false)", ! BooleanUtils.and(new boolean[] { true, true, false })); assertTrue( "True result for (true, false, true)", ! BooleanUtils.and(new boolean[] { true, false, true })); assertTrue( "True result for (false, true, true)", ! BooleanUtils.and(new boolean[] { false, true, true })); }
"True result for (false, false, true)", ! BooleanUtils .and( new Boolean[] { Boolean.FALSE, "True result for (false, true, false)", ! BooleanUtils .and( new Boolean[] { Boolean.FALSE, "True result for (true, false, false)", ! BooleanUtils .and( new Boolean[] { Boolean.TRUE, "False result for (true, true, true)", BooleanUtils .and(new Boolean[] { Boolean.TRUE, Boolean.TRUE, Boolean.TRUE }) .booleanValue()); ! BooleanUtils.and( new Boolean[] { Boolean.FALSE, ! BooleanUtils.and( new Boolean[] {
/** * 多个值的and */ public static boolean and(final boolean... array) { return BooleanUtils.and(array); }
/** * 多个值的and */ public static boolean and(final boolean... array) { return BooleanUtils.and(array); }
/** * 多个值的and */ public static boolean and(final boolean... array) { return BooleanUtils.and(array); }
private static Boolean and(final Collection<Boolean> booleans) { return BooleanUtils.and(booleans.toArray(new Boolean[booleans.size()])); }
return and(primitive) ? Boolean.TRUE : Boolean.FALSE; } catch (final NullPointerException ex) { throw new IllegalArgumentException("The array must not contain any null elements");
return and(primitive) ? Boolean.TRUE : Boolean.FALSE; } catch (final NullPointerException ex) { throw new IllegalArgumentException("The array must not contain any null elements");
return and(primitive) ? Boolean.TRUE : Boolean.FALSE; } catch (final NullPointerException ex) { throw new IllegalArgumentException("The array must not contain any null elements");