Java stream with equal, always returning null
up vote
-3
down vote
favorite
Additional question about my last problem..
BigDecimal fee;
fee = fees.stream()
.filter(p -> p.getTodate().isAfter(LocalDateTime.now()))
.filter(p -> p.getFromdate().isBefore(LocalDateTime.now()))
.filter(p -> p.getId().equals("001001"))
.map(Fee::getFee)
.findFirst()
.map(BigDecimal::new)
.orElse(new BigDecimal(1000));
return fee;
I first check that the fee is up to date, as there might be upcoming fees and fees that are no longer valid. Then I try to match the id with remaining fees.
The problem is the last filter.
i've checked multiple times and in data, there is exactly 1 entry with current date and this very same id. (it was input before but for debugging purposes i've hardcoded it for now)
and if i take date filters off this will still only return BigDecimal 1000.
What am i not seeing here?
Both values are Strings
java java-stream equals
|
show 14 more comments
up vote
-3
down vote
favorite
Additional question about my last problem..
BigDecimal fee;
fee = fees.stream()
.filter(p -> p.getTodate().isAfter(LocalDateTime.now()))
.filter(p -> p.getFromdate().isBefore(LocalDateTime.now()))
.filter(p -> p.getId().equals("001001"))
.map(Fee::getFee)
.findFirst()
.map(BigDecimal::new)
.orElse(new BigDecimal(1000));
return fee;
I first check that the fee is up to date, as there might be upcoming fees and fees that are no longer valid. Then I try to match the id with remaining fees.
The problem is the last filter.
i've checked multiple times and in data, there is exactly 1 entry with current date and this very same id. (it was input before but for debugging purposes i've hardcoded it for now)
and if i take date filters off this will still only return BigDecimal 1000.
What am i not seeing here?
Both values are Strings
java java-stream equals
maybe getFee returns an empty list. You should try the result with just the filters to see if the issue is really on the filter behaviour...
– snap
Nov 9 at 11:14
@snap done that, data is coming through just fine
– Clomez
Nov 9 at 11:15
2
can you juste provide a exemple Code as stackoverflow.com/help/mcve
– Arnault Le Prévost-Corvellec
Nov 9 at 11:48
2
to provide a runnable code to handle your issue .... 45 people read your post none have answer beacause we can t solve your issue without testing it to understand what really happen in your code that make it fail. the issue is clearly not directly in your snippet
– Arnault Le Prévost-Corvellec
Nov 9 at 12:27
1
This definitively requires a Minimal, Complete, and Verifiable example.
– Didier L
Nov 9 at 13:14
|
show 14 more comments
up vote
-3
down vote
favorite
up vote
-3
down vote
favorite
Additional question about my last problem..
BigDecimal fee;
fee = fees.stream()
.filter(p -> p.getTodate().isAfter(LocalDateTime.now()))
.filter(p -> p.getFromdate().isBefore(LocalDateTime.now()))
.filter(p -> p.getId().equals("001001"))
.map(Fee::getFee)
.findFirst()
.map(BigDecimal::new)
.orElse(new BigDecimal(1000));
return fee;
I first check that the fee is up to date, as there might be upcoming fees and fees that are no longer valid. Then I try to match the id with remaining fees.
The problem is the last filter.
i've checked multiple times and in data, there is exactly 1 entry with current date and this very same id. (it was input before but for debugging purposes i've hardcoded it for now)
and if i take date filters off this will still only return BigDecimal 1000.
What am i not seeing here?
Both values are Strings
java java-stream equals
Additional question about my last problem..
BigDecimal fee;
fee = fees.stream()
.filter(p -> p.getTodate().isAfter(LocalDateTime.now()))
.filter(p -> p.getFromdate().isBefore(LocalDateTime.now()))
.filter(p -> p.getId().equals("001001"))
.map(Fee::getFee)
.findFirst()
.map(BigDecimal::new)
.orElse(new BigDecimal(1000));
return fee;
I first check that the fee is up to date, as there might be upcoming fees and fees that are no longer valid. Then I try to match the id with remaining fees.
The problem is the last filter.
i've checked multiple times and in data, there is exactly 1 entry with current date and this very same id. (it was input before but for debugging purposes i've hardcoded it for now)
and if i take date filters off this will still only return BigDecimal 1000.
What am i not seeing here?
Both values are Strings
java java-stream equals
java java-stream equals
asked Nov 9 at 11:06
Clomez
12512
12512
maybe getFee returns an empty list. You should try the result with just the filters to see if the issue is really on the filter behaviour...
– snap
Nov 9 at 11:14
@snap done that, data is coming through just fine
– Clomez
Nov 9 at 11:15
2
can you juste provide a exemple Code as stackoverflow.com/help/mcve
– Arnault Le Prévost-Corvellec
Nov 9 at 11:48
2
to provide a runnable code to handle your issue .... 45 people read your post none have answer beacause we can t solve your issue without testing it to understand what really happen in your code that make it fail. the issue is clearly not directly in your snippet
– Arnault Le Prévost-Corvellec
Nov 9 at 12:27
1
This definitively requires a Minimal, Complete, and Verifiable example.
– Didier L
Nov 9 at 13:14
|
show 14 more comments
maybe getFee returns an empty list. You should try the result with just the filters to see if the issue is really on the filter behaviour...
– snap
Nov 9 at 11:14
@snap done that, data is coming through just fine
– Clomez
Nov 9 at 11:15
2
can you juste provide a exemple Code as stackoverflow.com/help/mcve
– Arnault Le Prévost-Corvellec
Nov 9 at 11:48
2
to provide a runnable code to handle your issue .... 45 people read your post none have answer beacause we can t solve your issue without testing it to understand what really happen in your code that make it fail. the issue is clearly not directly in your snippet
– Arnault Le Prévost-Corvellec
Nov 9 at 12:27
1
This definitively requires a Minimal, Complete, and Verifiable example.
– Didier L
Nov 9 at 13:14
maybe getFee returns an empty list. You should try the result with just the filters to see if the issue is really on the filter behaviour...
– snap
Nov 9 at 11:14
maybe getFee returns an empty list. You should try the result with just the filters to see if the issue is really on the filter behaviour...
– snap
Nov 9 at 11:14
@snap done that, data is coming through just fine
– Clomez
Nov 9 at 11:15
@snap done that, data is coming through just fine
– Clomez
Nov 9 at 11:15
2
2
can you juste provide a exemple Code as stackoverflow.com/help/mcve
– Arnault Le Prévost-Corvellec
Nov 9 at 11:48
can you juste provide a exemple Code as stackoverflow.com/help/mcve
– Arnault Le Prévost-Corvellec
Nov 9 at 11:48
2
2
to provide a runnable code to handle your issue .... 45 people read your post none have answer beacause we can t solve your issue without testing it to understand what really happen in your code that make it fail. the issue is clearly not directly in your snippet
– Arnault Le Prévost-Corvellec
Nov 9 at 12:27
to provide a runnable code to handle your issue .... 45 people read your post none have answer beacause we can t solve your issue without testing it to understand what really happen in your code that make it fail. the issue is clearly not directly in your snippet
– Arnault Le Prévost-Corvellec
Nov 9 at 12:27
1
1
This definitively requires a Minimal, Complete, and Verifiable example.
– Didier L
Nov 9 at 13:14
This definitively requires a Minimal, Complete, and Verifiable example.
– Didier L
Nov 9 at 13:14
|
show 14 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Well..
Not really an answer but i ran out of time and did the exact same thing
with regular old for loop, and everything went just as expected and worked just fine...
So i will still not use streams going forward..
EDIT:
code
for(Fee fee : fees){
if(fee.getId.equals(id)){
if(fee.getFromdate().isBefore(LocalDateTime.now())){
if(fee.getTodate().isAfter(LocalDateTime.now())){
BigDecimal z = new BigDecimal(fee.getFundservicefee());
return z.movePointLeft(2);
}
}
}
}
1
Please include the code that was used to fix the problem in case anyone has a similar issue in the future.
– JPadley
Nov 13 at 8:04
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Well..
Not really an answer but i ran out of time and did the exact same thing
with regular old for loop, and everything went just as expected and worked just fine...
So i will still not use streams going forward..
EDIT:
code
for(Fee fee : fees){
if(fee.getId.equals(id)){
if(fee.getFromdate().isBefore(LocalDateTime.now())){
if(fee.getTodate().isAfter(LocalDateTime.now())){
BigDecimal z = new BigDecimal(fee.getFundservicefee());
return z.movePointLeft(2);
}
}
}
}
1
Please include the code that was used to fix the problem in case anyone has a similar issue in the future.
– JPadley
Nov 13 at 8:04
add a comment |
up vote
0
down vote
accepted
Well..
Not really an answer but i ran out of time and did the exact same thing
with regular old for loop, and everything went just as expected and worked just fine...
So i will still not use streams going forward..
EDIT:
code
for(Fee fee : fees){
if(fee.getId.equals(id)){
if(fee.getFromdate().isBefore(LocalDateTime.now())){
if(fee.getTodate().isAfter(LocalDateTime.now())){
BigDecimal z = new BigDecimal(fee.getFundservicefee());
return z.movePointLeft(2);
}
}
}
}
1
Please include the code that was used to fix the problem in case anyone has a similar issue in the future.
– JPadley
Nov 13 at 8:04
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Well..
Not really an answer but i ran out of time and did the exact same thing
with regular old for loop, and everything went just as expected and worked just fine...
So i will still not use streams going forward..
EDIT:
code
for(Fee fee : fees){
if(fee.getId.equals(id)){
if(fee.getFromdate().isBefore(LocalDateTime.now())){
if(fee.getTodate().isAfter(LocalDateTime.now())){
BigDecimal z = new BigDecimal(fee.getFundservicefee());
return z.movePointLeft(2);
}
}
}
}
Well..
Not really an answer but i ran out of time and did the exact same thing
with regular old for loop, and everything went just as expected and worked just fine...
So i will still not use streams going forward..
EDIT:
code
for(Fee fee : fees){
if(fee.getId.equals(id)){
if(fee.getFromdate().isBefore(LocalDateTime.now())){
if(fee.getTodate().isAfter(LocalDateTime.now())){
BigDecimal z = new BigDecimal(fee.getFundservicefee());
return z.movePointLeft(2);
}
}
}
}
edited Nov 13 at 8:08
answered Nov 13 at 7:56
Clomez
12512
12512
1
Please include the code that was used to fix the problem in case anyone has a similar issue in the future.
– JPadley
Nov 13 at 8:04
add a comment |
1
Please include the code that was used to fix the problem in case anyone has a similar issue in the future.
– JPadley
Nov 13 at 8:04
1
1
Please include the code that was used to fix the problem in case anyone has a similar issue in the future.
– JPadley
Nov 13 at 8:04
Please include the code that was used to fix the problem in case anyone has a similar issue in the future.
– JPadley
Nov 13 at 8:04
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224542%2fjava-stream-with-equal-always-returning-null%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
maybe getFee returns an empty list. You should try the result with just the filters to see if the issue is really on the filter behaviour...
– snap
Nov 9 at 11:14
@snap done that, data is coming through just fine
– Clomez
Nov 9 at 11:15
2
can you juste provide a exemple Code as stackoverflow.com/help/mcve
– Arnault Le Prévost-Corvellec
Nov 9 at 11:48
2
to provide a runnable code to handle your issue .... 45 people read your post none have answer beacause we can t solve your issue without testing it to understand what really happen in your code that make it fail. the issue is clearly not directly in your snippet
– Arnault Le Prévost-Corvellec
Nov 9 at 12:27
1
This definitively requires a Minimal, Complete, and Verifiable example.
– Didier L
Nov 9 at 13:14