/** * Check if array contains item. * * @param array Array to examine * @param arrayLength Number of items to check, from the start of the array * @param contains Single item to look for * @param <T> The type of the array items * @return {@code true} if {@code contains} exists in {@code array}, otherwise {@code false}. */ @Deprecated public static <T> boolean contains( T[] array, int arrayLength, T contains ) { for ( int i = 0; i < arrayLength; i++ ) { T item = array[i]; if ( nullSafeEquals( item, contains ) ) { return true; } } return false; }
@Test void shouldCheckNullSafeEqual() { // WHEN/THEN assertTrue( ArrayUtil.nullSafeEquals( null, null ) ); assertFalse( ArrayUtil.nullSafeEquals( "1", null ) ); assertFalse( ArrayUtil.nullSafeEquals( null, "1" ) ); assertTrue( ArrayUtil.nullSafeEquals( "1", "1" ) ); }
/** * Check if array contains item. * * @param array Array to examine * @param arrayLength Number of items to check, from the start of the array * @param contains Single item to look for * @param <T> The type of the array items * @return {@code true} if {@code contains} exists in {@code array}, otherwise {@code false}. */ @Deprecated public static <T> boolean contains( T[] array, int arrayLength, T contains ) { for ( int i = 0; i < arrayLength; i++ ) { T item = array[i]; if ( nullSafeEquals( item, contains ) ) { return true; } } return false; }