Skip to content

Commit

Permalink
replace lambda with for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
skudikala committed Jun 13, 2024
1 parent 1949ac4 commit 169d695
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.hubspot.rosetta.annotations.RosettaSerialize;
import com.hubspot.rosetta.annotations.RosettaValue;
import com.hubspot.rosetta.annotations.StoredAsJson;
import java.util.Arrays;
import java.util.Optional;
import java.util.function.Supplier;

Expand Down Expand Up @@ -219,11 +218,12 @@ private Annotated getAnnotatedTypeFromAnnotatedMethod(AnnotatedMethod a) {
}

private <T> Optional<T> getFirstNonEmpty(Supplier<Optional<T>>... suppliers) {
return Arrays
.stream(suppliers)
.map(Supplier::get)
.filter(Optional::isPresent)
.findFirst()
.orElse(Optional.empty());
for (Supplier<Optional<T>> supplier : suppliers) {
Optional<T> maybeValue = supplier.get();
if (maybeValue.isPresent()) {
return maybeValue;
}
}
return Optional.empty();
}
}

0 comments on commit 169d695

Please sign in to comment.