0
Hello.
I want to do something like metodo(Class<? extends ClasseAbstrata> classe), only that of an abstract class, I want to use a interface, but I’ve moved on from extends for implements the eclipse starts pointing an error.
What I do?
Another question is that you trade the abstract class for one interface, and leave extends (Class<? extends Interface>), the eclipse does not point error, but does not make: public class Classe extends Interface { ....
Is this an eclipse error? Or is there some kind of class that can be made like this?
I have three classes that implement the interface (Acao), And created another interface (AcaoController), and that interface has the method public void inicializaEdicao(Class<?> classe); and I want him to receive all the methods they implement Acao.
Interface:
public interface Acao {
public String dadosParaGravacao();
public Person criaPerson();
}
Class Compromisso:
public class Compromisso implements Acao {
...
@Override
public String dadosParaGravacao() {
return new StringBuilder().append(descricao)
.append("|").append(titulo)
.append("|").append(importancia)
.append("|").append(feito)
.append("|").append(atrazado)
.append("|").append(horario.toString())
.append("|").append(dataDeCriacao.toString())
.append("|").append(dataDoFinal.toString())
.append("|").toString();
}
@Override
public Person criaPerson() {
return new CompromissoPerson(titulo, importancia, feito);
}
}
Class Projeto:
public class Projeto implements Acao {
...
@Override
public String dadosParaGravacao() {
return new StringBuilder().append(descricao)
.append("|").append(titulo)
.append("|").append(importancia)
.append("|").append(feito)
.append("|").append(atrazado)
.append("|").append(dataDeCriacao.toString())
.append("|").append(dataDoFinal.toString())
.append("|").toString();
}
@Override
public Person criaPerson() {
return new ProjetoPerson(titulo, importancia, feito);
}
}
Class Favorito:
public class Favorito implements Acao {
...
@Override
public String dadosParaGravacao() {
return new StringBuilder().append(descricao)
.append("|").append(titulo)
.append("|").append(importancia)
.append("|").append(link)
.append("|").append(dataDeCriacao.toString())
.append("|").toString();
}
@Override
public Person criaPerson() {
return new FavoritoPerson(titulo, importancia, dataDeCriacao.toString());
}
}
Interface AcaoController:
public interface AcaoController {
public List<Person> novo();
public void inicializaEdicao(Class<?> classe);
}
The error continues:

Because not only
public void inicializaEdicao(Acao a);? What your controller does that it needs the class and not the instance?– Victor Stafusa
I didn’t realize that. Thank you.
– lucas daniel
Then change the parameter to the type
Acaoresolved?– Victor Stafusa
There was no problem. So yes.
– lucas daniel