1
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 Calls, where I have to locate a call by your ID, on 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 cannot overwrite the equals, because it is already overwritten comparing all values... =/
Public Class Passo
- You know that thepublic
and theclass
should be in lower case, right?– Victor Stafusa
Correct, Victor. =)
– HagaHood
Simply make a
for
who searches the list for an element that contains the desired id and returns that element ornull
case not found does not solve for you?– Piovezan
Dude, I don’t understand your example. The chunk of code you gave doesn’t compile or filling what is missing in an imaginative way, because in the line
int index = atd.indexOf(atd.element.id = idAtendimento);
theidAtendimento
is an uninitialized variable. In addition, the assignment within theindexOf
seems to me very suspicious and confused. Also,Atendimento(atd.get(index))
also does not compile becauseAtendimento
is a class, not a method. Also, you don’t know what it isutil.GetAtendimento
.– Victor Stafusa