I have the following objects
public class Passo {
private Long id;
private Date dataAtend;
private Time horaRealizada;
private Long idProfissionalRealizador;
private String Descricao;
/*getter & Setters*/
}
public class Atendimento
{
private Long id;
private Date dataAtend;
private Long idPaciente;
private Long idProfissionalResponsavel;
private List<Passo> passos;
/*getter & Setters*/
public void addPasso(Passo passo){
passos.add(passo)
}
}
And I have a list of appointments, where I have to find a service by your ID, in this list, and insert more Steps. Something like that
...{
List<Atendimento> atd = new ArrayList<Atendimento>();
int idAtendimento;
Passo passo;
/* Trecho de codigo*/
int index = atd.indexOf(atd.element.id = idAtendimento);
if (index > 0 )
{
Atendimento(atd.get(index)).addPasso(passo);
}
else
{
Atendimento atend =util.GetAtendimento(idAtendimento);
atend.addPasso(passo);
atd.add(atend);
}
}
I can not overwrite equals, since it is already overwritten by comparing all values ... = /