All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jacobmountain.graphql.client.utils.OptionalUtils Maven / Gradle / Ivy

package com.jacobmountain.graphql.client.utils;

import lombok.experimental.UtilityClass;

import java.util.Arrays;
import java.util.Optional;
import java.util.function.Supplier;

@UtilityClass
public class OptionalUtils {

    @SafeVarargs
    public  Optional first(Optional first, Supplier>... later) {
        if (first.isPresent()) {
            return first;
        }
        if (later.length == 0) {
            return Optional.empty();
        }
        Optional head = later[0].get();
        return first(head, Arrays.copyOfRange(later, 1, later.length));
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy