com.github.leeonky.util.function.If Maven / Gradle / Ivy
The newest version!
package com.github.leeonky.util.function;
import java.util.Optional;
import java.util.function.Supplier;
public interface If {
static T firstNonNull(T... inputs) {
for (T other : inputs) {
if (other != null)
return other;
}
return null;
}
boolean is();
default Optional optional(Supplier factory) {
if (is())
return Optional.ofNullable(factory.get());
return Optional.empty();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy