Skip to content

Commit 79ec17b

Browse files
committed
Code polishing
1 parent 3d045fc commit 79ec17b

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

src/main/java/org/mybatis/dynamic/sql/render/RenderingStrategy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ public String getFormattedJdbcPlaceholder(String prefix, String parameterName) {
3232
return getFormattedJdbcPlaceholder(Optional.empty(), prefix, parameterName);
3333
}
3434

35-
public abstract String getFormattedJdbcPlaceholder(Optional<BindableColumn<?>> column, String prefix, String parameterName);
35+
public abstract String getFormattedJdbcPlaceholder(Optional<BindableColumn<?>> column, String prefix,
36+
String parameterName);
3637
}

src/main/java/org/mybatis/dynamic/sql/select/render/SelectRenderer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,15 @@ private String orderByPhrase(SortSpecification column) {
7979
}
8080

8181
private String renderLimit(Map<String, Object> parameters, Long limit) {
82-
String placeholder = renderingStrategy.getFormattedJdbcPlaceholder(RenderingStrategy.DEFAULT_PARAMETER_PREFIX, LIMIT_PARAMETER);
82+
String placeholder = renderingStrategy.getFormattedJdbcPlaceholder(RenderingStrategy.DEFAULT_PARAMETER_PREFIX,
83+
LIMIT_PARAMETER);
8384
parameters.put(LIMIT_PARAMETER, limit);
8485
return "limit " + placeholder; //$NON-NLS-1$
8586
}
8687

8788
private String renderOffset(Map<String, Object> parameters, Long offset) {
88-
String placeholder = renderingStrategy.getFormattedJdbcPlaceholder(RenderingStrategy.DEFAULT_PARAMETER_PREFIX, OFFSET_PARAMETER);
89+
String placeholder = renderingStrategy.getFormattedJdbcPlaceholder(RenderingStrategy.DEFAULT_PARAMETER_PREFIX,
90+
OFFSET_PARAMETER);
8991
parameters.put(OFFSET_PARAMETER, offset);
9092
return "offset " + placeholder; //$NON-NLS-1$
9193
}

src/test/java/examples/springbatch/cursor/SpringBatchCursorTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.springframework.batch.core.ExitStatus;
2929
import org.springframework.batch.core.JobExecution;
3030
import org.springframework.batch.core.StepExecution;
31+
import org.springframework.batch.item.ExecutionContext;
3132
import org.springframework.batch.test.JobLauncherTestUtils;
3233
import org.springframework.batch.test.context.SpringBatchTest;
3334
import org.springframework.beans.factory.annotation.Autowired;
@@ -61,10 +62,14 @@ public void testThatRowsAreTransformedToUpperCase() throws Exception {
6162
private int numberOfRowsProcessed(JobExecution jobExecution) {
6263
return jobExecution.getStepExecutions().stream()
6364
.map(StepExecution::getExecutionContext)
64-
.mapToInt(ec -> ec.getInt("row_count"))
65+
.mapToInt(this::getRowCount)
6566
.sum();
6667
}
6768

69+
private int getRowCount(ExecutionContext executionContext) {
70+
return executionContext.getInt("row_count", 0);
71+
}
72+
6873
private long upperCaseRowCount() throws Exception {
6974
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
7075
PersonMapper personMapper = sqlSession.getMapper(PersonMapper.class);

src/test/java/examples/springbatch/paging/SpringBatchPagingTest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.springframework.batch.core.ExitStatus;
2929
import org.springframework.batch.core.JobExecution;
3030
import org.springframework.batch.core.StepExecution;
31+
import org.springframework.batch.item.ExecutionContext;
3132
import org.springframework.batch.test.JobLauncherTestUtils;
3233
import org.springframework.batch.test.context.SpringBatchTest;
3334
import org.springframework.beans.factory.annotation.Autowired;
@@ -62,17 +63,25 @@ public void testThatRowsAreTransformedToUpperCase() throws Exception {
6263
private int numberOfRowsProcessed(JobExecution jobExecution) {
6364
return jobExecution.getStepExecutions().stream()
6465
.map(StepExecution::getExecutionContext)
65-
.mapToInt(ec -> ec.getInt("row_count"))
66+
.mapToInt(this::getRowCount)
6667
.sum();
6768
}
6869

70+
private int getRowCount(ExecutionContext executionContext) {
71+
return executionContext.getInt("row_count", 0);
72+
}
73+
6974
private int numberOfChunks(JobExecution jobExecution) {
7075
return jobExecution.getStepExecutions().stream()
7176
.map(StepExecution::getExecutionContext)
72-
.mapToInt(ec -> ec.getInt("chunk_count"))
77+
.mapToInt(this::getChunkCount)
7378
.sum();
7479
}
7580

81+
private int getChunkCount(ExecutionContext executionContext) {
82+
return executionContext.getInt("chunk_count", 0);
83+
}
84+
7685
private long upperCaseRowCount() throws Exception {
7786
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
7887
PersonMapper personMapper = sqlSession.getMapper(PersonMapper.class);

0 commit comments

Comments
 (0)