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










share|improve this question






















  • 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















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










share|improve this question






















  • 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













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










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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












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);
}
}
}
}





share|improve this answer



















  • 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











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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

























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);
}
}
}
}





share|improve this answer



















  • 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















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);
}
}
}
}





share|improve this answer



















  • 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













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);
}
}
}
}





share|improve this answer














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);
}
}
}
}






share|improve this answer














share|improve this answer



share|improve this answer








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














  • 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


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff