Java 8 – How to sort list with stream.sorted()
Few examples to show you how to sort a List with stream.sorted(): Sort a List with Comparator.naturalOrder(), Sort a List with Comparator.reverseOrder(), Sort a List user objects.
Java 8 – How to convert IntStream to int or int[]
Few Java 8 examples to get a primitive int from an IntStream. We can convert IntStream to primitive int array.
Java 8 – How to convert IntStream to Integer[]
How to convert IntStream to Integer array? The key is boxed() the IntStream into a Stream, then only convert to an Array.
Java 8 – Should we close the Stream after use?
Streams have a BaseStream.close() method and implement AutoCloseable, but nearly all stream instances do not actually need to be closed after use. Generally, only streams whose source is an IO…
Java 8 Stream – The peek() is not working with count()?
Many examples are using the .count() as the terminal operation for .peek(). However, for Java 9 and above, the peek() may print nothing. Since Java 9, if JDK compiler is…
Java 8 Stream – Convert List of List Strings to List Strings
As title, we can use flatMap to convert it. Similar to convert 2D array to 1D array using Stream.flatMap.
Techniques For Designing Your API and Microservices
A design that initially looks good may not be the best design to easily solve the problems at hand. Too often, our initial assumptions about our API and microservice designs…
Before you design your API, model your API
I’m often asked which is the better style of API: REST, GraphQL, or gRPC. My answer is always: “I’m not sure. What does your API model say?” At this point,…
API Design Guidance: Long-Running Background Jobs
The REST style is particularly suited for synchronous APIs, where requests generally return quickly (less than a few seconds). For operations that take a longer time to complete, it may…