@@ -0,0 +1,2203 @@
+package com.levelup.java.guava;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport java.util.List;%0A%0Aimport org.junit.Test;%0A%0Aimport com.google.common.collect.Lists;%0Aimport com.google.common.primitives.Booleans;%0A%0A/**%0A * This example demostrates uses of Google guavas Booleans, static utility%0A * methods pertaining to boolean primitives that are not found in Boolean or Arrays.%0A * %0A * @author Justin Musgrove%0A * @see %3Ca href='http://www.leveluplunch.com/java/examples/guava-booleans-utility-example/'%3EBooleans utility example%3C/a%3E%0A */%0Apublic class BooleansExample %7B%0A%09%0A%09%0A%09@Test%0A%09public void count_total_number_of_booleans () %7B%0A%09%09%0A%09%09boolean %5B%5D values = %7Btrue, true, false, true, false%7D;%0A%09%09%0A%09%09int count = Booleans.countTrue(values);%0A%09%09%0A%09%09assertEquals(3, count);%0A%09%7D%0A%09%0A%09@Test%0A%09public void convert_boolean_array_to_Boolean_list () %7B%0A%0A%09%09boolean%5B%5D booleanArray = %7Btrue, false, true, false%7D;%0A%09%09%0A%09%09List%3CBoolean%3E booleans = Booleans.asList(booleanArray);%0A%09%09%0A%09%09assertEquals(4, booleans.size());%0A%09%7D%0A%09%0A%09@Test%0A%09public void concat_boolean_arrays () %7B%0A%0A%09%09boolean%5B%5D booleanArray1 = %7Btrue, false%7D;%0A%09%09boolean%5B%5D booleanArray2 = %7Btrue, false%7D;%0A%0A%09%09boolean%5B%5D concatedArray = Booleans.concat(booleanArray1, booleanArray2);%0A%09%09%0A%09%09assertEquals(4, concatedArray.length);%0A%09%7D%0A%09%0A%09@Test%0A%09public void boolean_array_contains () %7B%0A%09%09%0A%09%09boolean%5B%5D booleanArray = %7Btrue, false, true, false%7D;%0A%0A%09%09boolean arrayContains = Booleans.contains(booleanArray, true);%0A%09%09%0A%09%09assertTrue(arrayContains);%0A%09%7D%0A%09%0A%09@Test%0A%09public void boolean_array_index () %7B%0A%0A%09%09boolean%5B%5D booleanArray = %7Btrue, false, true, false%7D;%0A%0A%09%09int index = Booleans.indexOf(booleanArray, false);%0A%09%09%0A%09%09assertEquals(1, index);%0A%09%7D%0A%09%0A%09@Test%0A%09public void join_elements_of_boolean_array () %7B%0A%0A%09%09boolean%5B%5D booleanArray = %7Btrue, false, true, false%7D;%0A%0A%09%09String joinedElements = Booleans.join(%22-%22, booleanArray);%0A%09%09%0A%09%09assertEquals(%22true-false-true-false%22, joinedElements);%0A%09%7D%0A%09%0A%09@Test%0A%09public void convert_Boolean_to_primitive () %7B%0A%0A%09%09List%3CBoolean%3E booleans = Lists.newArrayList(%0A%09%09%09%09Boolean.TRUE, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE);%0A%09%09%0A%09%09boolean%5B%5D primitiveArray = Booleans.toArray(booleans);%0A%09%09%0A%09%09assertEquals(4, primitiveArray.length);%0A%09%7D%09%09%0A%0A%7D%0A

add google guava booleans example