什么可能是最短的代码:
public void update(final Product object, final Callback<Product> callback) {
if(object.getIsDayDependent()) {
Double priceDay0 = object.getSundayPrice();
Double priceDay1 = object.getMondayPrice();
Double priceDay2 = object.getTuesdayPrice();
Double priceDay3 = object.getWednesdayPrice();
Double priceDay4 = object.getThursdayPrice();
Double priceDay5 = object.getFridayPrice();
Double priceDay6 = object.getSaturdayPrice();
List<DayPrice> dayPrices = new LinkedList<>();
dayPrices.add(new DayPrice(0, priceDay0));
dayPrices.add(new DayPrice(1, priceDay1));
dayPrices.add(new DayPrice(2, priceDay2));
dayPrices.add(new DayPrice(3, priceDay3));
dayPrices.add(new DayPrice(4, priceDay4));
dayPrices.add(new DayPrice(5, priceDay5));
dayPrices.add(new DayPrice(6, priceDay6));
object.setDayDependent(dayPrices);
} else {
object.setPrice(null);
object.setDayDependent(new LinkedList<>());
}
callback.onSuccess(object);
}
收到一只叮咚
翻阅古今
相关分类