2
I have the following research method:
public class Pesquisa {
private static <O> ObservableList<O> pesquisarPorNome(ObservableList<O> listaObservavel, String pesquisa) {
ObservableList<O> novaLista = FXCollections.observableArrayList();
for(int x = 0; x<listaObservavel.size(); x++) {
if(listaObservavel.get(x).getNome().toLowerCase().contains(pesquisa.toLowerCase()));
novaLista.add(listaObservavel.get(x));
}
return novaLista;
}
I don’t want to write this method in all classes, so I created this method separate from all classes containing the method getNome()
will use. I generalized everything and beauty, but error precisely in the method getNome()
saying that he does not recognize this method.
How can I tell the compiler that all ObservableList
that I will pass as argument will contain this method?
Remembering that I will pass ObservableLists
of several different classes, but they will always contain a getNome()
.
Hello, thanks for the response, I made a Searchable interface, everything worked fine at first, but at the time I called the method searchName(Observablelist<Searchable> listObservavel, String search) passing as argument Search.search(mainApp.getGruposData(), searchTextField.gettext()) not a Group, being that Group implements Searchable,?
– Gabriel Henrique
It’s too confusing to answer and it’s another question.
– Maniero