This code doesn't look too good. Could anyone help me format it?
private void initComparisonDatatable() {
List<BrandProfitAndLoss> brandProfitAndLossComparisonDatatable = new ArrayList<BrandProfitAndLoss>();
BrandProfitAndLoss brandProfitAndLossCurrentYear = new BrandProfitAndLoss();
BrandProfitAndLoss brandProfitAndLossPreviousYear = new BrandProfitAndLoss();
// if the selected year is null and the previous year is not null
if(brandActionForm.getBrandProfitLossList().size() <= 0 && brandActionForm.getBrandProfitLossComparisonList().size() > 0){
for(int i = 0; i < brandActionForm.getBrandProfitLossComparisonList().size(); i++){
brandProfitAndLossPreviousYear = brandActionForm.getBrandProfitLossComparisonList().get(i);
brandProfitAndLossCurrentYear = new BrandProfitAndLoss(brandActionForm.getBrandProfitLossComparisonList().get(i).getDate(), brandActionForm.getDateMode(), Consts.CURRENT_YEAR);
brandProfitAndLossComparisonDatatable.add(brandProfitAndLossCurrentYear);
brandProfitAndLossComparisonDatatable.add(brandProfitAndLossPreviousYear);
brandProfitAndLossComparisonDatatable.add(new BrandProfitAndLoss().getAllRateComparisonRecords(brandProfitAndLossCurrentYear
, brandProfitAndLossPreviousYear));
}
}
// the selected year is not null
else {
for(int i = 0; i < brandActionForm.getBrandProfitLossList().size(); i++){
brandProfitAndLossCurrentYear = brandActionForm.getBrandProfitLossList().get(i);
brandProfitAndLossComparisonDatatable.add(brandProfitAndLossCurrentYear);
if(brandActionForm.getBrandProfitLossComparisonList().size() > 0){
brandProfitAndLossPreviousYear = brandActionForm.getBrandProfitLossComparisonList().get(i);
brandProfitAndLossComparisonDatatable.add(brandProfitAndLossPreviousYear);
brandProfitAndLossComparisonDatatable.add(new BrandProfitAndLoss().getAllRateComparisonRecords(brandProfitAndLossCurrentYear
, brandProfitAndLossPreviousYear));
}
else {
brandProfitAndLossPreviousYear = new BrandProfitAndLoss(brandActionForm.getBrandProfitLossList().get(i).getDate(), brandActionForm.getDateMode(), Consts.CURRENT_YEAR);
brandProfitAndLossComparisonDatatable.add(brandProfitAndLossPreviousYear);
brandProfitAndLossComparisonDatatable.add(new BrandProfitAndLoss().getAllRateComparisonRecords(brandActionForm.getBrandProfitLossList().get(i)
, brandProfitAndLossPreviousYear));
}
}
}
brandActionForm.setBrandProfitLossComparisonListForDatatable(brandProfitAndLossComparisonDatatable);
}