Skip to content
Advertisement

Tag: java-8

Java 8 edit stream elements

I need to filter and modify the values of the filtered object. The logic that must be filtered is given below. I have tried it like this. But how can we set the value of isUpdated = true using java 8? Answer Base on the logic given, findFirst should be used as you stop after the first instance is found.

Sort List of Values in a Map in descending order

I have a Map with List of Doubles. unsorted map contents: {A=[0.02, 0.03], B=[0.0, 0.01], C=[0.01, 0.0], D=[0.05, 1.03], E=[1.01, 0.03]} I need to sort in descending order for List(0). I have tried the below logic but its sorting in ascending order. Actual output: {B=[0.0, 0.01], C=[0.01, 0.0], A=[0.02, 0.03], D=[0.05, 1.03], E=[1.01, 0.03]} Expected output: {E=[1.01, 0.03], D=[0.05, 1.03],

Java 8 Optional: combine two possibly null object

I have to ensure if two values are non null. When the first and second have non null values, pass first as argument to second. If one of them are null value, then return false. This can be done in the following piece of code: It can also be done in short form: I was wondering how to do this

Consumer does not read messages from the Kafka topic (Akka Stream Kafka)

We use Akka Stream Kafka for producing and consuming messages and Strimzi Kafka cluster. Here are the versions if matters: After a refactoring message consumer stopped working. We do have messages in the topic, but consumer just waits endlessly. Here is the log fragment: Some more points: Schema registry properly configured and good (otherwise producer would not work). Topic (and

Advertisement