All Questions
Tagged with functional-programming java
1,388 questions
0
votes
0
answers
39
views
Introducing Reader Monad to propagate the initial request
I'm using Java. I built a small library for internal use.
The idea is from F" railway oriented programming : developing a pipeline by composing functions
1. The basic block
@FunctionalInterface
...
0
votes
0
answers
30
views
Non-static method cannot be referenced from a static contex error using Comparator [duplicate]
Even after reading documentations and multiple posts about this error I still don't understand the following case:
This line will generate the error Non-static method cannot be referenced from a ...
0
votes
2
answers
71
views
What is the way to chain methods with different signatures describing a business process?
I have the following process I'd like to describe with chained methods returning Either.
The process receives a context object containing a WhateverInput and correlationId and processes these in the ...
1
vote
0
answers
49
views
Why do I need to specify the types of the Map.Entry. Is it because the types of the keys are different? [duplicate]
The following code results in the error:
Non-static method cannot be referenced from a static context
public static Optional<String> getAuthorWithMostPublishedBooks(){
return books.stream()...
0
votes
0
answers
34
views
Java Stream API memory consumption of multiple .filter() in chain [duplicate]
Have a question regarding .filter (or any other non-terminal) methods in Stream API chain (code in the block below is just for example):
var s1 = Stream.of(1,2,3,4,5,6,7,8,9);
var intemidiate1 = s1....
3
votes
1
answer
105
views
Base class not recoginsed while using wild card generic
Why is the below not working?
A b1 = new B();
Function<? super B, ? extends A> function = x -> new B();
A apply = function.apply(b1);
It gives an error "Required type capture of ? ...
0
votes
0
answers
62
views
How to put setter function as a parameter?
I need to rewrite the test so that the setter function is passed as a parameter. That is, inside the test, I create a valid book, take an invalid value from the parameter, take the function, and this ...
1
vote
0
answers
33
views
batch for update entities list by NamedQuery and function with Pair as input
I've found very interesting but not implemented method in some CoreDao Interface:
import org.apache.commons.lang3.tuple.Pair;
import javax.management.Query;
import java.util.List;
import java.util....
-1
votes
1
answer
158
views
Could Java stream create memory overhead [closed]
What I got from basic principle of Java streams is that it works on immutable objects and does operation and collect (if we collect it as collection) as new immutable objects.
Does that means for any ...
0
votes
0
answers
113
views
How to use Stream.collect with specific class as suplider
I am a student.
You might think I'm overloading the code with this, unnecessarily, but the goal is just to improve the understanding of the collect method. So all these components that I mention are ...
1
vote
1
answer
60
views
Unexpected results working on Array of Integers
While going through and re-factoring some Java code I wrote a while back for Project-Euler.
I ran into an issue with integer overflow where the answer was too large to contain in type int. This was ...
-1
votes
1
answer
86
views
Transforming Java POJOs and nested streams(Java 8), with possibility of null inner stream
Say I have following java POJOs
class Outer {
Config;
List<Warning> warnings;
}
class Config {
String configId;
String configName;
}
class Warning {
String warningId;
String ...
1
vote
0
answers
61
views
Do I need declare as volatile the supplier class member in order to preserve thread-safety
I am reading this book "Functional Programming in Java Harnessing the Power Of Java 8 Lambda Expressions" and in chapter 6 (lazy evaluations) there's an example of heavy object creation. ...
-3
votes
1
answer
75
views
Setting up different Java class fields value by a single value on some counter value [closed]
Setting up different Java class fields value by a single value on some counter value?
In a Java class, having similar kind of fields like:
public class User {
private String user_Id_1;
private ...
1
vote
1
answer
111
views
Grouping by multiple fields and counting using in Java 8
I have a Person table in database and the associated domain class looks like below:
public class Person {
private String firstName;
private String secondName;
private String city;
...