Boa tarde!
Tenho uma classe que preciso preenche-lá porém com uma entidade, até ai sempre problemas, porém preciso receber vários tipos que construtores que irão server de filtro para ir no banco de dados e com o resultado preencher a classe.
Estou com problemas na implementação, alguém tem uma luz? Segue código:
public final class YearQuarter extends Number implements Comparable<YearQuarter>, Cloneable {
private final int year;
private final int quarter;
private final DateTime firstDay;
private final DateTime lastDay;
public final static YearQuarter getInfinite() {
return new YearQuarter(INFINITE);
}
public final static YearQuarter getInstance(Object o) {
if (o != null)
try {
if (o instanceof Number)
return new YearQuarter((Number) o);
else if (o instanceof DateTime)
return new YearQuarter((DateTime) o);
else if (o instanceof YearQuarter)
return (YearQuarter) o;
} catch (Exception e) {
// noop
}
return null;
}
public final static YearQuarter getInstance(CommercialAwardingProgramQuarter o) {
if (o != null)
try {
return new YearQuarter(o);
} catch (Exception e) {
// noop
}
return null;
}
private static int quarterFromMonth(int month) {
return (month - 1) / 3 + 1;
}
private static int firstMonthFromQuarter(int quarter) {
return quarter * 3 - 2;
}
public YearQuarter() {
this(new DateTime());
}
public YearQuarter(CommercialAwardingProgramQuarter commercialAwardingProgramQuarter) {
/* recebe Entidade como construtor */
this.year = commercialAwardingProgramQuarter.getYear().getYear();
this.firstDay = commercialAwardingProgramQuarter.getValidFrom();
this.lastDay = commercialAwardingProgramQuarter.getValidTo();
this.quarter = commercialAwardingProgramQuarter.getQuarter();
this.infinite = false;
this.fullQuarter = year * 10 + quarter;
}
public YearQuarter(Number value) {
checkArgument(value != null, "Cannot get a quarter from a null number.");
/*
* Pega o numero passado e busca no banco
*/
this.quarter = quarter;
this.year = year;
this.fullQuarter = year * 10 + quarter;
this.lastDay = null;
this.firstDay = null;
}
public YearQuarter(DateTime date) {
checkArgument(date != null, "The date cannot be null.");
/*
* Pega data passada busca valores correspondentes no banco e preenche a classe
*/
}
}