Java examples for java.lang:Assert
Assert List is Unique Element
//package com.java2s; import java.util.List; public class Main { public static void main(String[] argv) throws Exception { List list = java.util.Arrays.asList("asdf", "java2s.com"); System.out.println(isUniqueElement(list)); }//from w w w . j a v a 2s .co m public static <E> boolean isUniqueElement(List<E> list) { return (isNotNull(list) && list.size() == 1); } public static <E> boolean isUniqueElement(E... array) { return (isNotNull(array) && array.length == 1); } public static boolean isNotNull(Object object) { return object != null; } }