- You could use local variables to decrease the amount of repetition. Say
bySize = garments.get(i).getSizes().get(j)
for example. - instead of
size.getXxsml()
,size.getXsml()
etc. you could use an enum for sizes and loop on sizes.
The whole thing would then look like:
for(int j=0;j<garments.get(i).getSizes().size();j++) {
bySize = garments.get(i).getSizes().get(j);
for (Size s : Size.values()) {
if (bySize.get(s) > 0) {
garmentString.append(garmentSizes(i, s, bySize.get(s)));
}
}
}
The bySize.get(s)
method could be implemented either with a switch that directs to the right method or directly in the enum and you could get rid of the getXsml
etc. methods.