/* 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
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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 org.camunda.bpm.dmn.engine.impl.hitpolicy;

import java.util.ArrayList;
import java.util.List;

import org.camunda.bpm.dmn.engine.DmnDecisionOutput;
import org.camunda.bpm.dmn.engine.DmnDecisionResult;
import org.camunda.bpm.dmn.engine.DmnDecisionTable;

public class CollectCountAggregator extends AbstractDmnHitPolicyAggregator {

  public DmnDecisionResult aggregate(DmnDecisionTable decisionTable, List<DmnDecisionOutput> decisionOutputs) {
    long count = collectSingleValues(decisionOutputs).size();
    String name = getDecisionOutputName(decisionOutputs);

    return createAggregatedDecisionResult(name, count);
  }

  protected List<Integer> convertValuesToInteger(List<Object> values) {
    List<Integer> intValues = new ArrayList<Integer>();
    for (Object value : values) {
      if (value instanceof Integer) {
        intValues.add((Integer) value);
      }
      else {
        try {
          intValues.add(Integer.valueOf(value.toString()));
        }
        catch (NumberFormatException e) {
          throw LOG.unableToConvertValueTo(Integer.class, value, e);
        }
      }
    }
    return intValues;
  }

  protected List<Long> convertValuesToLong(List<Object> values) {
    List<Long> longValues = new ArrayList<Long>();
    for (Object value : values) {
      if (value instanceof Long) {
        longValues.add((Long) value);
      }
      else {
        try {
          longValues.add(Long.valueOf(value.toString()));
        }
        catch (NumberFormatException e) {
          throw LOG.unableToConvertValueTo(Long.class, value, e);
        }
      }
    }
    return longValues;
  }

  protected List<Double> convertValuesToDouble(List<Object> values) {
    List<Double> doubleValues = new ArrayList<Double>();

    for (Object value : values) {
      if (value instanceof Double) {
        doubleValues.add((Double) value);
      }
      else {
        try {
          doubleValues.add(Double.valueOf(value.toString()));
        }
        catch (NumberFormatException e) {
          throw LOG.unableToConvertValueTo(Double.class, value, e);
        }
      }
    }

    return doubleValues;
  }
}

@@ -609,36 +609,8 @@
 y;%0A%0A
-import java.util.ArrayList;%0A
 impo
@@ -1164,1512 +1164,6 @@
  %7D%0A%0A
-  protected List%3CInteger%3E convertValuesToInteger(List%3CObject%3E values) %7B%0A    List%3CInteger%3E intValues = new ArrayList%3CInteger%3E();%0A    for (Object value : values) %7B%0A      if (value instanceof Integer) %7B%0A        intValues.add((Integer) value);%0A      %7D%0A      else %7B%0A        try %7B%0A          intValues.add(Integer.valueOf(value.toString()));%0A        %7D%0A        catch (NumberFormatException e) %7B%0A          throw LOG.unableToConvertValueTo(Integer.class, value, e);%0A        %7D%0A      %7D%0A    %7D%0A    return intValues;%0A  %7D%0A%0A  protected List%3CLong%3E convertValuesToLong(List%3CObject%3E values) %7B%0A    List%3CLong%3E longValues = new ArrayList%3CLong%3E();%0A    for (Object value : values) %7B%0A      if (value instanceof Long) %7B%0A        longValues.add((Long) value);%0A      %7D%0A      else %7B%0A        try %7B%0A          longValues.add(Long.valueOf(value.toString()));%0A        %7D%0A        catch (NumberFormatException e) %7B%0A          throw LOG.unableToConvertValueTo(Long.class, value, e);%0A        %7D%0A      %7D%0A    %7D%0A    return longValues;%0A  %7D%0A%0A  protected List%3CDouble%3E convertValuesToDouble(List%3CObject%3E values) %7B%0A    List%3CDouble%3E doubleValues = new ArrayList%3CDouble%3E();%0A%0A    for (Object value : values) %7B%0A      if (value instanceof Double) %7B%0A        doubleValues.add((Double) value);%0A      %7D%0A      else %7B%0A        try %7B%0A          doubleValues.add(Double.valueOf(value.toString()));%0A        %7D%0A        catch (NumberFormatException e) %7B%0A          throw LOG.unableToConvertValueTo(Double.class, value, e);%0A        %7D%0A      %7D%0A    %7D%0A%0A    return doubleValues;%0A  %7D%0A
 %7D%0A

remove unused code