public static Optional<Object> firstElement(final Object obj) {
        val object = toCollection(obj);
        if (object.isEmpty()) {
            return Optional.empty();
        }
        return Optional.of(object.iterator().next());
    }
Converts the provided object into a collection
and return the first element, or empty.

@param obj the obj
@return the optional
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/CollectionUtils.java