StatisticsResult () { int total = mySucceed.size() + myFailed.size(); if (mySucceed.isEmpty() && myFailed.isEmpty()) { return new StatisticsResult(StatisticsResult.ResultCode.NOTHING_TO_SEND, "No files to upload."); } else if (!myFailed.isEmpty()) { final StringBuilder out = new StringBuilder("{\"total\":"); out.append(total).append(", \"uploaded\":").append(mySucceed.size()).append(","); out.append("\"failed\":["); append(out, myFailed); out.append("],\"succeed\":["); append(out, mySucceed); out.append("]}"); return new StatisticsResult(StatisticsResult.ResultCode.SENT_WITH_ERRORS, out.toString()); } final StringBuilder out = new StringBuilder("{\"total\":"); out.append(total).append(", \"uploaded\":").append(mySucceed.size()).append(","); out.append("\"succeed\":["); append(out, mySucceed); out.append("]}"); return new StatisticsResult(StatisticsResult.ResultCode.SEND, out.toString()); }