@SuppressWarnings("unchecked")
    @SafeVarargs
    public static <T> Optional<T> or(final Supplier<Optional<? extends T>>... optionals) {
        return (Optional<T>) Arrays.stream(optionals)
                .map(Supplier::get)
                .filter(Optional::isPresent)
                .findFirst()
                .orElseGet(Optional::empty);
    }
@ SuppressWarnings ( "unchecked" ) @ SafeVarargs public static < T > Optional < T > or ( final Supplier < Optional < ? extends T > > ... optionals ) { return ( Optional < T > ) Arrays . stream ( optionals ) . map ( Supplier :: get ) . filter ( Optional :: isPresent ) . findFirst ( ) . orElseGet ( Optional :: empty ) ; }
Return the first optional to be defined.

@param optionals the lambdas returning the optionals
@param <T> The type
@return the first non-empty or empty