Last active
March 4, 2020 14:18
-
-
Save gaalha/6d35395b93d4b930cc72c8f69e16370a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Catch valores nulos | |
disabledUsersOnLDAP.stream() | |
.map(User::getUsername) | |
.map(usersRepository::findEnabledByUsername) | |
.filter(Objects::nonNull) // <-- Util | |
.forEach(userEntity -> userEntity.setEnabled(false)); | |
// Obtener el número máximo de una lista | |
Integer lastPaysheetPaymentId = lst.stream() | |
.mapToInt(VwRecalculatedRent::getPaysheetPaymentDetailId) | |
.max() | |
.orElseThrow(NoSuchElementException::new); | |
// Sumar valores de una lista | |
Double promisesAmount = accountPaymentsList.stream() | |
.mapToDouble(AccountPayments::getAmount) | |
.filter(Objects::nonNull) | |
.sum(); | |
// Guardar una propiedad de una lista en otra lista | |
List<Integer> lstCurrent = paymentPlanListOfCurrentMonth.stream() | |
.map(VwPaymentPlanToChart::getCount) | |
.collect(Collectors.toList()); | |
// Unir dos listas sin repetir valores iguales | |
ArrayList<String> listOne = new ArrayList<>(Arrays.asList("a", "b", "c", "d", "e")); | |
ArrayList<String> listTwo = new ArrayList<>(Arrays.asList("a", "b", "c", "f", "g")); | |
List<String> combinedList = Stream.concat( | |
listOne.stream(), | |
listTwo.stream()) | |
.distinct() | |
.collect(Collectors.toList()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment