Java 8 lambda, une égalité d'Integer ne fonctionne pas
Bonjour,
J'ai un souci d'égalité d'Integer dans une expression lambda qui ne fonctionne pas et je ne comprend pas pourquoi, pourriez vous m'aidez ?
D'abord j'ai ce code complètement fonctionnel :
Type :
this.intervention = un objet Intervention
this.getInterventions() = une liste d'Intervention
i.getIdIntervention() = l'Id de l'intervention (Integer)
this.navigationBean.getIdIntervention() = retourne l'Id de l'intervention de l'url (Integer)
Code:
1 2
|
this.intervention = this.getInterventions().stream().filter(i -> i.getIdIntervention().equals(this.navigationBean.getIdIntervention())).findFirst().get(); |
Ce code fonctionne parfaitement le lambda me renvoie bien une Intervention, pas de souci, c'est la suite qui se complique :
Je fait la même chose pour un Objectif :
Type :
this.objectif = un objet Objectif
this.intervention.getObjectifs() = liste d'Objectif dans l'Intervention
i.getIdTache() = l'id de l'Objectif (Integer) (Objectif hérite de Tache)
this.navigationBean.getIdObjectif() = l'Id de l'objectif dans l'url (Integer)
Code:
1 2
|
this.objectif = this.intervention.getObjectifs().stream().filter(i -> i.getIdTache().equals(this.navigationBean.getIdObjectif())).findFirst().get(); |
Et cette fois ça ne marche pas, il me dit que qu'il ne trouve pas d'objet correspondant alors que :
Code:
1 2 3 4 5 6
|
for(Objectif o : this.intervention.getObjectifs()){
if(o.getIdTache().equals(this.navigationBean.getIdObjectif())){
this.objectif = o;
}
} |
Fonctionne parfaitement !
Si vous avez une idée je suis preneur, je ne comprend vraiment pas ....