Skip to content

Instantly share code, notes, and snippets.

@pellse
Last active November 6, 2017 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pellse/b7098563757230bb93b417c1481c0859 to your computer and use it in GitHub Desktop.
Save pellse/b7098563757230bb93b417c1481c0859 to your computer and use it in GitHub Desktop.
private void handleAllOrdersOf(List<Customer> customers) {
Optional.ofNullable(customers)
.map(unchecked(this::queryDatabaseForAllOrders)) // Sneaky throw, SQLException
.orElseGet(Collections::emptyList)
.forEach(this::processOrder);
}
public List queryDatabaseForAllOrders(List<Customer> customers) throws SQLException {
// Query database, retrieve all orders for all customers
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment