All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ca.uhn.hl7v2.util.ArrayUtil Maven / Gradle / Ivy

There is a newer version: 2.5.1
Show newest version
package ca.uhn.hl7v2.util;

/**
 * Utility methods for working with arrays
 */
public class ArrayUtil {

	/**
	 * Returns true if the array contains the given value, using
	 * {@link Object#equals(Object)}. Checks for a null value
	 * in the array if theValue is null.
     *
     * @param theArray the array to be checked
     * @param theValue value to be search for
	 */
	public static  boolean contains(T[] theArray, T theValue) {
		for (T next : theArray) {
			if (theValue == null) {
				if (next == null) {
					return true;
				}
			} else {
				if (theValue.equals(next)) {
					return true;
				}
			}
		}
		return false;
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy