class CompositeDateTimeDecider implements Decider {

    @SuppressWarnings("null")
    @Override
    public List<Pair<DateColumn, Integer>> compileResults(List<Pair<PotentialColumn, Integer>> potentials)
    {
        PotentialColumn datePart = null;
        SuccessfulFormat dateFormat = null;
        Integer datePartScore = null;
        PotentialColumn timePart = null;
        SuccessfulFormat timeFormat = null;
        Integer timePartScore = null;

        for (Pair<PotentialColumn, Integer> potential : potentials)
        {
            PotentialColumn column = potential.getFirstObject();
            SuccessfulFormat successfulFormat = column.getMostSuccessfulFormat();

            if (successfulFormat != null && successfulFormat.getFormat() != null
                    && successfulFormat.getFormat().getType() == Type.DATE && datePart == null)
            {
                datePart = column;
                dateFormat = successfulFormat;
                datePartScore = potential.getSecondObject();
            }

            if (successfulFormat != null && successfulFormat.getFormat() != null
                    && successfulFormat.getFormat().getType() == Type.TIME && timePart == null)
            {
                timePart = column;
                timeFormat = successfulFormat;
                timePartScore = potential.getSecondObject();
            }

            if (datePart != null && timePart != null)
            {
                break;
            }
        }

        List<Pair<DateColumn, Integer>> result = New.list();

        if (dateFormat != null && timeFormat != null)
        {
            DateColumn column = new DateColumn();
            column.setDateColumnType(Type.TIMESTAMP);
            column.setPrimaryColumnFormat(dateFormat.getFormat().getSdf());
            column.setPrimaryColumnIndex(datePart.getColumnIndex());
            column.setSecondaryColumnFormat(timeFormat.getFormat().getSdf());
            column.setSecondaryColumnIndex(timePart.getColumnIndex());

            int score = (datePartScore.intValue() + timePartScore.intValue()) / 2;

            result.add(new Pair<DateColumn, Integer>(column, Integer.valueOf(score)));
        }

        return result;
    }

}