Java Code Examples for com.google.common.primitives.Booleans#indexOf()

The following examples show how to use com.google.common.primitives.Booleans#indexOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Conversions.java    From xtext-lib with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws NullPointerException
 *             if the wrapped array was <code>null</code>.
 */
@Override
public int indexOf(Object o) {
	// Will make the method fail if array is null.
	if (size() < 1) {
		return -1;
	}
	if (o instanceof Boolean) {
		return Booleans.indexOf(array, ((Boolean) o).booleanValue());
	}
	return -1;
}
 
Example 2
Source File: BooleansExample.java    From levelup-java-examples with Apache License 2.0 3 votes vote down vote up
@Test
public void boolean_array_index () {

	boolean[] booleanArray = {true, false, true, false};

	int index = Booleans.indexOf(booleanArray, false);
	
	assertEquals(1, index);
}