EMMA Coverage Report (generated Thu Jan 24 13:37:04 CST 2013)
[all classes][org.springframework.batch.core.partition.support]

COVERAGE SUMMARY FOR SOURCE FILE [DefaultStepExecutionAggregator.java]

nameclass, %method, %block, %line, %
DefaultStepExecutionAggregator.java100% (1/1)100% (2/2)100% (79/79)100% (16/16)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DefaultStepExecutionAggregator100% (1/1)100% (2/2)100% (79/79)100% (16/16)
DefaultStepExecutionAggregator (): void 100% (1/1)100% (3/3)100% (1/1)
aggregate (StepExecution, Collection): void 100% (1/1)100% (76/76)100% (15/15)

1/*
2 * Copyright 2006-2007 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17package org.springframework.batch.core.partition.support;
18 
19import java.util.Collection;
20 
21import org.springframework.batch.core.BatchStatus;
22import org.springframework.batch.core.ExitStatus;
23import org.springframework.batch.core.StepExecution;
24import org.springframework.util.Assert;
25 
26/**
27 * Convenience class for aggregating a set of {@link StepExecution} instances
28 * into a single result.
29 * 
30 * @author Dave Syer
31 * @since 2.1
32 */
33public class DefaultStepExecutionAggregator implements StepExecutionAggregator {
34 
35        /**
36         * Aggregates the input executions into the result {@link StepExecution}.
37         * The aggregated fields are
38         * <ul>
39         * <li>status - choosing the highest value using
40         * {@link BatchStatus#max(BatchStatus, BatchStatus)}</li>
41         * <li>exitStatus - using {@link ExitStatus#and(ExitStatus)}</li>
42         * <li>commitCount, rollbackCount, etc. - by arithmetic sum</li>
43         * </ul>
44         * @see StepExecutionAggregator #aggregate(StepExecution, Collection)
45         */
46        public void aggregate(StepExecution result, Collection<StepExecution> executions) {
47                Assert.notNull(result, "To aggregate into a result it must be non-null.");
48                if (executions == null) {
49                        return;
50                }
51                for (StepExecution stepExecution : executions) {
52                        BatchStatus status = stepExecution.getStatus();
53                        result.setStatus(BatchStatus.max(result.getStatus(), status));
54                        result.setExitStatus(result.getExitStatus().and(stepExecution.getExitStatus()));
55                        result.setCommitCount(result.getCommitCount() + stepExecution.getCommitCount());
56                        result.setRollbackCount(result.getRollbackCount() + stepExecution.getRollbackCount());
57                        result.setReadCount(result.getReadCount() + stepExecution.getReadCount());
58                        result.setReadSkipCount(result.getReadSkipCount() + stepExecution.getReadSkipCount());
59                        result.setWriteCount(result.getWriteCount() + stepExecution.getWriteCount());
60                        result.setWriteSkipCount(result.getWriteSkipCount() + stepExecution.getWriteSkipCount());
61                }
62        }
63 
64}

[all classes][org.springframework.batch.core.partition.support]
EMMA 2.0.5312 (C) Vladimir Roubtsov