/**
 * AET
 * <p>
 * Copyright (C) 2013 Cognifide Limited
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.cognifide.aet.job.common.comparators.requestmonitoring.utils;

import java.util.Collection;
import java.util.Collections;
import java.util.TreeSet;

public class RequestMonitoringResults {

  private final Collection<RequestMonitoringResult> results;

  public RequestMonitoringResults() {
    results = new TreeSet<>(Collections.reverseOrder());
  }

  public final void addItem(String url, long bodySize) {
    RequestMonitoringResult item = new RequestMonitoringResult(url, bodySize);
    results.add(item);
  }

  public Collection<RequestMonitoringResult> getResults() {
    return results;
  }

  public double getTotalSize() {
    return results.stream().map(RequestMonitoringResult::getSize).reduce(0.0, Double::sum);
  }
}

@@ -879,16 +879,45 @@
 sults;%0A%0A
+  private double totalSize;%0A%0A
   public
@@ -942,24 +942,24 @@
 Results() %7B%0A
-
     results 
@@ -1003,16 +1003,36 @@
 der());%0A
+    totalSize = 0d;%0A
   %7D%0A%0A  p
@@ -1183,24 +1183,57 @@
 .add(item);%0A
+    totalSize += item.getSize();%0A
   %7D%0A%0A  publi
@@ -1358,87 +1358,17 @@
 urn 
-results.stream().map(RequestMonitoringResult::getSize).reduce(0.0, Double::sum)
+totalSize
 ;%0A  

fix totalSize filed json serialization