Hello.
I want to do something like metodo(Class<? extends ClasseAbstrata> classe)
, except that an abstract class, I want to use a interface
, but if I change from extends
to implements
eclipse starts to point an error. >
What do I do?
Another question is that if I change the abstract class by a interface
, and I leave extends
( Class<? extends Interface>
), eclipse does not point to error but does not: public class Classe extends Interface { ...
.
Is this an eclipse error? Or is there some kind of class that can be done like this?
I have three classes that implement interface
( Acao
), and I created another interface
( AcaoController
), and this interface
has method public void inicializaEdicao(Class<?> classe);
and I want it to receive all methods which 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: