Returns the first element, if any, of an object that may be an {@link Iterable}

@param maybeIterable
@return
424925
public static Object getFirstElement(Object maybeIterable) {
    if (!(maybeIterable instanceof Iterable<?>)) return null;
    Iterable<?> iterable = (Iterable<?>) maybeIterable;
    Iterator<?> iterator = iterable.iterator();
    return iterator.hasNext() ? iterator.next() : null;
  }
465462
public static <T> Iterator<T> iteratorOverIterables(
        Iterable<? extends T> iterable0, Iterable<? extends T> iterable1)
    {
        Objects.requireNonNull(iterable0, "The iterable0 is null");
        Objects.requireNonNull(iterable1, "The iterable1 is null");
        List<Iterable<? extends T>> iterables =
            new ArrayList<Iterable<? extends T>>(2);
        iterables.add(iterable0);
        iterables.add(iterable1);
        return iteratorOverIterables(iterables.iterator());
    }
490249
public static Class<?> getElementType(Iterable<?> iterable) {
		if (null != iterable) {
			final Iterator<?> iterator = iterable.iterator();
			return getElementType(iterator);
		}
		return null;
	}
683223
public int addFirst(Iterable<? extends KTypeCursor<? extends KType>> iterable) {
    int size = 0;
    for (KTypeCursor<? extends KType> cursor : iterable) {
      addFirst(cursor.value);
      size++;
    }
    return size;
  }
1171996
public static <T> LazyIterable<T> select(Iterable<T> iterable, Predicate<? super T> predicate)
    {
        return new SelectIterable<T>(iterable, predicate);
    }
578048
public static <E> E first(Iterator<E> iterator) {
        return new FirstElement<E>().apply(iterator);
    }
130267
private Iterator<Object> getValueIterator(HasContainer c) {
    return c.getPredicate().getBiPredicate() == Contains.within ?
        ((Iterable<Object>) c.getValue()).iterator() :
        IteratorUtils.of(c.getValue());
  }
415422
public static <T> Iterable<T> iterableOf(Iterator<T> it) {
        final Iterator<T> theIt = Require.nonNull(it, "it");
        return new Iterable<T>() {

            @Override
            public Iterator<T> iterator() {
                return theIt;
            }
        };
    }
79578
public V getFirst(Object key) {
        List<V> res = getAll(key);
        if (res.isEmpty()) {
            return null;
        } else {
            return res.iterator().next();
        }
    }
1284662
public static <E> Optional<E> maybeAt(long index, Iterable<E> iterable) {
        dbc.precondition(iterable != null, "cannot call maybeAt with a null iterable");
        final Iterator<E> filtered = new FilteringIterator<E>(iterable.iterator(), new AtIndex<E>(index));
        return new MaybeFirstElement<E>().apply(filtered);
    }
453351
public static <T> Iterable<T> nullSafeIterable(Iterable<T> iterable) {
        return (iterable != null) ? iterable : Collections.EMPTY_LIST;
    }
578215
public static <E> Iterable<E> iterable(final Enumeration<E> enumeration) {
        checkNotNull(enumeration, "Can not create an Iterable from a null enumeration");
        return new Iterable<E>() {
            public Iterator<E> iterator() {
                return new ImmutableIterator<E>() {
                    public boolean hasNext() {
                        return enumeration.hasMoreElements();
                    }

                    public E next() {
                        return enumeration.nextElement();
                    }
                };
            }
        };
    }
744785
public SerIterable createIterable(SerIterable iterable) {
        List<Class<?>> valueTypeTypes = iterable.valueTypeTypes();
        if (valueTypeTypes.size() > 0) {
            Class<?> valueType = iterable.valueType();
            if (NavigableSet.class.isAssignableFrom(valueType)) {
                return navigableSet(valueTypeTypes.get(0), EMPTY_VALUE_TYPES);
            }
            if (SortedSet.class.isAssignableFrom(valueType)) {
                return sortedSet(valueTypeTypes.get(0), EMPTY_VALUE_TYPES);
            }
            if (Set.class.isAssignableFrom(valueType)) {
                return set(valueTypeTypes.get(0), EMPTY_VALUE_TYPES);
            }
            if (Collection.class.isAssignableFrom(valueType)) {  // includes List
                return list(valueTypeTypes.get(0), EMPTY_VALUE_TYPES);
            }
            if (NavigableMap.class.isAssignableFrom(valueType)) {
                if (valueTypeTypes.size() == 2) {
                    return navigableMap(valueTypeTypes.get(0), valueTypeTypes.get(1), EMPTY_VALUE_TYPES);
                }
                return navigableMap(Object.class, Object.class, EMPTY_VALUE_TYPES);
            }
            if (SortedMap.class.isAssignableFrom(valueType)) {
                if (valueTypeTypes.size() == 2) {
                    return sortedMap(valueTypeTypes.get(0), valueTypeTypes.get(1), EMPTY_VALUE_TYPES);
                }
                return sortedMap(Object.class, Object.class, EMPTY_VALUE_TYPES);
            }
            if (Map.class.isAssignableFrom(valueType)) {
                if (valueTypeTypes.size() == 2) {
                    return map(valueTypeTypes.get(0), valueTypeTypes.get(1), EMPTY_VALUE_TYPES);
                }
                return map(Object.class, Object.class, EMPTY_VALUE_TYPES);
            }
            if (valueType.isArray()) {
                if (valueType.getComponentType().isPrimitive()) {
                    return arrayPrimitive(valueType.getComponentType());
                } else {
                    return array(valueType.getComponentType());
                }
            }
        }
        return null;
    }
188869
public Iterator<E> iterator() {

        return new Iterator<E>() {

            public boolean hasNext() {
                return enumeration.hasMoreElements();
            }

            public E next() {
                return enumeration.nextElement();
            }

            public void remove() {
                throw new UnsupportedOperationException("IterableEnumeration does not support remove");
            }
        };
    }
1010614
public static <T> boolean isEmpty(final Iterable<T> iterable) {
        return iterable == null || !iterable.iterator().hasNext();
    }
701120
public static <E> Optional<E> maybeOne(E[] array) {
        return new MaybeOneElement<E>().apply(new ArrayIterator<>(array));
    }
789024
public static <T> LazyIterable<T> distinct(Iterable<T> iterable)
    {
        return new DistinctIterable<T>(iterable);
    }