001package ca.uhn.hl7v2.util;
002
003/**
004 * Utility methods for working with arrays
005 */
006public class ArrayUtil {
007
008        /**
009         * Returns true if the array contains the given value, using
010         * {@link Object#equals(Object)}. Checks for a null value
011         * in the array if theValue is null.
012     *
013     * @param theArray the array to be checked
014     * @param theValue value to be search for
015         */
016        public static <T> boolean contains(T[] theArray, T theValue) {
017                for (T next : theArray) {
018                        if (theValue == null) {
019                                if (next == null) {
020                                        return true;
021                                }
022                        } else {
023                                if (theValue.equals(next)) {
024                                        return true;
025                                }
026                        }
027                }
028                return false;
029        }
030        
031}