View Javadoc
1   package ca.uhn.hl7v2.util;
2   
3   /**
4    * Utility methods for working with arrays
5    */
6   public class ArrayUtil {
7   
8   	/**
9   	 * Returns true if the array contains the given value, using
10  	 * {@link Object#equals(Object)}. Checks for a null value
11  	 * in the array if theValue is null.
12       *
13       * @param theArray the array to be checked
14       * @param theValue value to be search for
15  	 */
16  	public static <T> boolean contains(T[] theArray, T theValue) {
17  		for (T next : theArray) {
18  			if (theValue == null) {
19  				if (next == null) {
20  					return true;
21  				}
22  			} else {
23  				if (theValue.equals(next)) {
24  					return true;
25  				}
26  			}
27  		}
28  		return false;
29  	}
30  	
31  }