Extracts the first entry of the list when it is not null and contains values.

@param list The list to extract the first entry from, can be null
@return The first entry of the list when it is not null or empty, null otherwise
3733
public static <T> T firstEntry(final List<T> list) {
        if (list != null && !list.isEmpty()) {
            return list.get(0);
        } else {
            return null;
        }
    }
899697
@Deprecated
    public static String first(String list, String delimiter) {
	return first(list, delimiter, true, 1);
    }
1042468
public static <T> T getRandomItem(List<T> list) {
		return list.get(rand.nextInt(list.size()));
	}
1006869
private static <T> T firstOf(final List<T> list) {
        return list.isEmpty()? null: list.get(0);
    }
724
private synchronized List<Entry> getEntriesList( DirectoryEntry directory )
    {
        List<Entry> entries = contents.get( directory );
        if ( entries == null )
        {
            entries = new ArrayList<Entry>();
            contents.put( directory, entries );
        }
        return entries;
    }
734204
public static ListIterator listIterator(Object list)
    {
        if (list==null)
            return Collections.EMPTY_LIST.listIterator();
        if (list instanceof List)
            return ((List)list).listIterator();
        return getList(list).listIterator();
    }
890729
public static <T> T last( List<T> list )
    {
        return get( list, list.size() - 1 );
    }
574428
private static List<Integer> convertList(List<String> list) {
        if (list == null) {
            return null;
        }
        List<Integer> ret = new ArrayList<Integer>(list.size());
        for (String v : list) {
            ret.add(StringUtils.toInt(v));
        }

        return ret;
    }
942815
public static final String getSelectedText(ListBox list) {
	int index = list.getSelectedIndex();
	return (index >= 0) ? list.getItemText(index) : null;
    }
1025933
public static Object get(Object list, int i)
    {
        if (list==null)
            throw new IndexOutOfBoundsException();
        
        if (list instanceof List)
            return ((List)list).get(i);

        if (i==0)
            return list;
        
        throw new IndexOutOfBoundsException();
    }
735987
public static int listFindNoCase(String list, String value, String delimiter, boolean trim) {
	Array arr = trim ? listToArrayTrim(list, delimiter) : listToArray(list, delimiter);
	int len = arr.size();
	for (int i = 1; i <= len; i++) {
	    if (((String) arr.get(i, "")).equalsIgnoreCase(value)) return i - 1;
	}
	return -1;
    }
700210
public static int listFindNoCaseIgnoreEmpty(String list, String value, String delimiter) {
	if (delimiter.length() == 1) return listFindNoCaseIgnoreEmpty(list, value, delimiter.charAt(0));
	if (list == null) return -1;
	int len = list.length();
	if (len == 0) return -1;
	int last = 0;
	int count = 0;
	char[] del = delimiter.toCharArray();
	char c;

	for (int i = 0; i < len; i++) {
	    c = list.charAt(i);
	    for (int y = 0; y < del.length; y++) {
		if (c == del[y]) {
		    if (last < i) {
			if (list.substring(last, i).equalsIgnoreCase(value)) return count;
			count++;
		    }
		    last = i + 1;
		    break;
		}
	    }
	}
	if (last < len) {
	    if (list.substring(last).equalsIgnoreCase(value)) return count;
	}
	return -1;
    }
742505
@SuppressWarnings("unchecked")
    public static <E> E get(Object list, int i) {
        if (list == null)
            throw new IndexOutOfBoundsException();

        if (list instanceof List)
            return (E) ((List<?>) list).get(i);

        if (i == 0)
            return (E) list;

        throw new IndexOutOfBoundsException();
    }
925572
public static <T> T firstValue(List<T> list) {
        if (list != null && !list.isEmpty()) {
            return list.get(0);
        }
        return null;
    }
79578
public V getFirst(Object key) {
        List<V> res = getAll(key);
        if (res.isEmpty()) {
            return null;
        } else {
            return res.iterator().next();
        }
    }
1024843
public static int[] listToMap(int[] list) {
        list = pad(list);
        int[] bitMap = new int[(int)(list.length / WORD_LENGTH)];
        Arrays.fill(bitMap, 0);
        int j = -1;
        for (int i = 0; i < list.length; i++) {
            if (i % WORD_LENGTH == 0) {
                j++;
            }
            bitMap[j] |= (list[i] << ((WORD_LENGTH - 1) - (i % WORD_LENGTH)));
        }
        return bitMap;
    }
1094682
public static boolean hasEntry(Object list) {
        if (list == null)
            return false;
        if (list instanceof List)
            return !((List<?>) list).isEmpty();
        return true;
    }