This file has been truncated, but you can view the full file.
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
package com.theboreddev.springbootapp | |
import org.springframework.beans.factory.annotation.Autowired | |
import org.springframework.beans.factory.annotation.Value | |
import org.springframework.http.ResponseEntity | |
import org.springframework.web.bind.annotation.* | |
import org.springframework.web.util.UriComponentsBuilder | |
@RestController | |
@RequestMapping("/api/customers") |
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
public interface Processor { | |
Integer process(List<Integer> input) throws InterruptedException; | |
} |
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
private static final NavigableMap<Integer, String> ROMAN_NUMERALS = new TreeMap<>() { | |
{ | |
put(1, "I"); | |
put(4, "IV"); | |
put(5, "V"); | |
put(9, "IX"); | |
put(10, "X"); | |
put(50, "L"); | |
put(100, "C"); | |
put(500, "D"); |
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
CompletableFuture<Void> chain = new CompletableFuture<>(); | |
chain.thenComposeAsync(nil -> createUser()) | |
.thenAcceptAsync(logNewUserId()) | |
.thenComposeAsync(nil -> | |
registerAddress() | |
.thenAcceptBothAsync(registerPaymentDetails(), (address, paymentDetailsSuccess) -> { | |
System.out.println("Registered address was : " + address); | |
System.out.println("Registered payment details success : " + paymentDetailsSuccess); | |
}) |
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
CompletableFuture<String> subTask = new CompletableFuture<>(); | |
CompletableFuture<Result> chain = CompletableFuture.runAsync(() -> System.out.println("Start")) | |
.thenCombine(subTask, (nil, text) -> { | |
if (text == null || text.isEmpty()) | |
throw new IllegalArgumentException("Text cannot be null or empty!"); | |
return Result.COMPLETED; | |
}) | |
.completeOnTimeout(Result.TIMEOUT, 500, TimeUnit.MILLISECONDS) | |
.exceptionally(exception -> Result.FAILED); |
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
package com.theboreddev.examples.forkjoin; | |
import java.util.concurrent.ForkJoinPool; | |
import java.util.concurrent.ForkJoinTask; | |
import java.util.concurrent.RecursiveTask; | |
public class ForkJoinExample { | |
public static void main(String[] args) { |
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
final Collection<Employee> employees = List.of( | |
new Employee("Karen Smith", 51200.0, 29, Employee.Sex.FEMALE), | |
new Employee("John Smith", 24000.0, 32, Employee.Sex.MALE), | |
new Employee("Anthony Jackson", 44000.0, 33, Employee.Sex.MALE), | |
new Employee("Alyson Palmer", 34320.0, 36, Employee.Sex.FEMALE), | |
new Employee("Jessica Sanders", 64320.0, 34, Employee.Sex.FEMALE) | |
); | |
final Map<Employee.Sex, List<Employee>> employeesBySex = employees.stream() | |
.collect(groupingBy(Employee::getSex)); |
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
final Map<Employee.Sex, Set<Employee>> employeesBySex = employees.stream() | |
.collect(groupingBy(Employee::getSex, toSet())); |
NewerOlder