Cast problem

0

I have the following classes:

public class Hotran {

    @Getter
    @Setter
    private String codEmpresa;

    @Getter
    @Setter
    private String nomeEmpresa;

    @Getter
    @Setter
    private Long voo;

    @Getter
    @Setter
    private String equipamento;

    @Getter
    @Setter
    private List<String> diasDeVoo;

    @Getter
    @Setter
    private Long quantidadeAssentos;

    @Getter
    @Setter
    private String numeroHotran;

    @Getter
    @Setter
    private Date dataSolicitacao;

    @Getter
    @Setter
    private Date dataVigencia;

    @Getter
    @Setter
    private String naturezaOperacao;

    @Getter
    @Setter
    private Long numEtapa;

    @Getter
    @Setter
    private String codOrigem;

    @Getter
    @Setter
    private String aeroOrigem;

    @Getter
    @Setter
    private String codDestino;

    @Getter
    @Setter
    private String aeroDestino;

    @Getter
    @Setter
    private Date horaPartida;

    @Getter
    @Setter
    private Date horaChegada;

    @Getter
    @Setter
    private String equipAlterado;

    public Hotran() {
        this.diasDeVoo = new ArrayList<String>();
    }

With the subclass

public class HotranComParecer extends Hotran{

    @Getter
    @Setter
    private String hotranAnt;

    @Getter
    @Setter
    private String cgna;

    @Getter
    @Setter
    private String infraero;

    @Getter
    @Setter
    private String gatr;

    @Getter
    @Setter
    private String ggco;

    @Getter
    @Setter
    private String ggfs;

    @Getter
    @Setter
    private String ggip;

    @Getter
    @Setter
    private String ggof;

    @Getter
    @Setter
    private String ggta;

    @Getter
    @Setter
    private String gopi;

    @Getter
    @Setter
    private String gopd;

    @Getter
    @Setter
    private String consolidacao;

I have the following method:

private Hotran toBasicos(Row row) {
        Hotran hotran = new Hotran();
        for (Cell cell : row) {
            switch (cell.getColumnIndex()) {
            case 0:
                hotran.setCodEmpresa(PlanilhaUtil.toString(cell));
                break;
            case 1:
                hotran.setNomeEmpresa(PlanilhaUtil.toString(cell));
                break;
            case 2:
                hotran.setVoo(PlanilhaUtil.toLong(cell));
                break;
            case 3:
                hotran.setEquipamento(PlanilhaUtil.toString(cell));
                break;
            case 4:
                hotran.getDiasDeVoo().add(PlanilhaUtil.toString(cell));
                break;
            case 5:
                hotran.getDiasDeVoo().add(PlanilhaUtil.toString(cell));
                break;
            case 6:
                hotran.getDiasDeVoo().add(PlanilhaUtil.toString(cell));
                break;
            case 7:
                hotran.getDiasDeVoo().add(PlanilhaUtil.toString(cell));
                break;
            case 8:
                hotran.getDiasDeVoo().add(PlanilhaUtil.toString(cell));
                break;
            case 9:
                hotran.getDiasDeVoo().add(PlanilhaUtil.toString(cell));
                break;
            case 10:
                hotran.getDiasDeVoo().add(PlanilhaUtil.toString(cell));
                break;
            case 11:
                hotran.setQuantidadeAssentos(PlanilhaUtil.toLong(cell));
                break;
            case 12:
                hotran.setNumeroHotran(PlanilhaUtil.toString(cell));
                break;
            }
        }
        return hotran;
    }

When trying to do:

HotranComParecer hotran = (HotranComParecer) toBasicos(row);

I have the following error:

java.lang.ClassCastException: com.roknauta.alure.model.Hotran cannot be cast to com.roknauta.alure.model.HotranComParecer

Can anyone help me please?

    
asked by anonymous 27.12.2017 / 22:48

0 answers