Skip to content

Commit 24b8d72

Browse files
fmbenhassinemminella
authored andcommitted
Add JSR-305 annotations to public APIs
(Partially) Resolves BATCH-2688
1 parent 89a3b04 commit 24b8d72

File tree

100 files changed

+538
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+538
-182
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/ItemProcessListener.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2007 the original author or authors.
2+
* Copyright 2006-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616
package org.springframework.batch.core;
1717

1818
import org.springframework.batch.item.ItemProcessor;
19+
import org.springframework.lang.Nullable;
1920

2021
/**
2122
* Listener interface for the processing of an item. Implementations
@@ -24,6 +25,7 @@
2425
* exceptions thrown by the processor.
2526
*
2627
* @author Dave Syer
28+
* @author Mahmoud Ben Hassine
2729
*
2830
*/
2931
public interface ItemProcessListener<T, S> extends StepListener {
@@ -37,13 +39,13 @@ public interface ItemProcessListener<T, S> extends StepListener {
3739

3840
/**
3941
* Called after {@link ItemProcessor#process(Object)} returns. If the
40-
* processor returns null, this method will still be called, with
41-
* a null result, allowing for notification of 'filtered' items.
42+
* processor returns {@code null}, this method will still be called, with
43+
* a {code null} result, allowing for notification of 'filtered' items.
4244
*
4345
* @param item to be processed
4446
* @param result of processing
4547
*/
46-
void afterProcess(T item, S result);
48+
void afterProcess(T item, @Nullable S result);
4749

4850
/**
4951
* Called if an exception was thrown from {@link ItemProcessor#process(Object)}.

spring-batch-core/src/main/java/org/springframework/batch/core/ItemReadListener.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2008 the original author or authors.
2+
* Copyright 2006-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,11 +17,13 @@
1717

1818
import org.springframework.batch.item.ItemReader;
1919
import org.springframework.batch.item.ItemWriter;
20+
import org.springframework.lang.Nullable;
2021

2122
/**
2223
* Listener interface around the reading of an item.
2324
*
2425
* @author Lucas Ward
26+
* @author Mahmoud Ben Hassine
2527
*
2628
*/
2729
public interface ItemReadListener<T> extends StepListener {
@@ -36,7 +38,7 @@ public interface ItemReadListener<T> extends StepListener {
3638
*
3739
* @param item returned from read()
3840
*/
39-
void afterRead(T item);
41+
void afterRead(@Nullable T item);
4042

4143
/**
4244
* Called if an error occurs while trying to read.

spring-batch-core/src/main/java/org/springframework/batch/core/Job.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2007 the original author or authors.
2+
* Copyright 2006-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,14 +15,16 @@
1515
*/
1616
package org.springframework.batch.core;
1717

18+
import org.springframework.lang.Nullable;
19+
1820
/**
1921
* Batch domain object representing a job. Job is an explicit abstraction
2022
* representing the configuration of a job specified by a developer. It should
2123
* be noted that restart policy is applied to the job as a whole and not to a
2224
* step.
2325
*
2426
* @author Dave Syer
25-
*
27+
* @author Mahmoud Ben Hassine
2628
*/
2729
public interface Job {
2830

@@ -47,11 +49,12 @@ public interface Job {
4749

4850
/**
4951
* If clients need to generate new parameters for the next execution in a
50-
* sequence they can use this incrementer. The return value may be null, in
51-
* the case that this job does not have a natural sequence.
52+
* sequence they can use this incrementer. The return value may be {@code null},
53+
* in the case that this job does not have a natural sequence.
5254
*
5355
* @return in incrementer to be used for creating new parameters
5456
*/
57+
@Nullable
5558
JobParametersIncrementer getJobParametersIncrementer();
5659

5760
/**
@@ -60,8 +63,8 @@ public interface Job {
6063
* the execution.
6164
*
6265
* @return a validator that can be used to check parameter values (never
63-
* null)
66+
* {@code null})
6467
*/
6568
JobParametersValidator getJobParametersValidator();
6669

67-
}
70+
}

spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2017 the original author or authors.
2+
* Copyright 2006-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,12 +29,14 @@
2929
import java.util.concurrent.CopyOnWriteArrayList;
3030

3131
import org.springframework.batch.item.ExecutionContext;
32+
import org.springframework.lang.Nullable;
3233

3334
/**
3435
* Batch domain object representing the execution of a job.
3536
*
3637
* @author Lucas Ward
3738
* @author Michael Minella
39+
* @author Mahmoud Ben Hassine
3840
*
3941
*/
4042
@SuppressWarnings("serial")
@@ -91,7 +93,7 @@ public JobExecution(JobExecution original) {
9193
* @param jobConfigurationName {@link String} instance that represents the
9294
* job configuration name (used with JSR-352).
9395
*/
94-
public JobExecution(JobInstance job, Long id, JobParameters jobParameters, String jobConfigurationName) {
96+
public JobExecution(JobInstance job, Long id, @Nullable JobParameters jobParameters, String jobConfigurationName) {
9597
super(id);
9698
this.jobInstance = job;
9799
this.jobParameters = jobParameters == null ? new JobParameters() : jobParameters;

spring-batch-core/src/main/java/org/springframework/batch/core/JobKeyGenerator.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2013 the original author or authors.
2+
* Copyright 2013-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,11 +15,14 @@
1515
*/
1616
package org.springframework.batch.core;
1717

18+
import org.springframework.lang.Nullable;
19+
1820
/**
1921
* Strategy interface for the generation of the key used in identifying
2022
* unique {@link JobInstance}.
2123
*
2224
* @author Michael Minella
25+
* @author Mahmoud Ben Hassine
2326
*
2427
* @param <T> The type of the source data used to calculate the key.
2528
* @since 2.2
@@ -29,10 +32,10 @@ public interface JobKeyGenerator<T> {
2932
/**
3033
* Method to generate the unique key used to identify a job instance.
3134
*
32-
* @param source Source information used to generate the key
35+
* @param source Source information used to generate the key (can be {@code null})
3336
*
3437
* @return a unique string identifying the job based on the information
3538
* supplied
3639
*/
37-
String generateKey(T source);
40+
String generateKey(@Nullable T source);
3841
}

spring-batch-core/src/main/java/org/springframework/batch/core/JobParametersIncrementer.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2007 the original author or authors.
2+
* Copyright 2006-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,11 +15,14 @@
1515
*/
1616
package org.springframework.batch.core;
1717

18+
import org.springframework.lang.Nullable;
19+
1820
/**
1921
* Interface for obtaining the next {@link JobParameters} in a sequence.
2022
*
2123
* @author Dave Syer
2224
* @author Lucas Ward
25+
* @author Mahmoud Ben Hassine
2326
* @since 2.0
2427
*/
2528
public interface JobParametersIncrementer {
@@ -30,8 +33,8 @@ public interface JobParametersIncrementer {
3033
* instance of a job.
3134
*
3235
* @param parameters the last value used
33-
* @return the next value to use
36+
* @return the next value to use (never {@code null})
3437
*/
35-
JobParameters getNext(JobParameters parameters);
38+
JobParameters getNext(@Nullable JobParameters parameters);
3639

3740
}

spring-batch-core/src/main/java/org/springframework/batch/core/JobParametersValidator.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010 the original author or authors.
2+
* Copyright 2010-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,23 +15,25 @@
1515
*/
1616
package org.springframework.batch.core;
1717

18+
import org.springframework.lang.Nullable;
1819

1920
/**
2021
* Strategy interface for a {@link Job} to use in validating its parameters for
2122
* an execution.
2223
*
2324
* @author Dave Syer
24-
*
25+
* @author Mahmoud Ben Hassine
26+
*
2527
*/
2628
public interface JobParametersValidator {
2729

2830
/**
2931
* Check the parameters meet whatever requirements are appropriate, and
3032
* throw an exception if not.
3133
*
32-
* @param parameters some {@link JobParameters}
34+
* @param parameters some {@link JobParameters} (can be {@code null})
3335
* @throws JobParametersInvalidException if the parameters are invalid
3436
*/
35-
void validate(JobParameters parameters) throws JobParametersInvalidException;
37+
void validate(@Nullable JobParameters parameters) throws JobParametersInvalidException;
3638

3739
}

spring-batch-core/src/main/java/org/springframework/batch/core/StepExecutionListener.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2013 the original author or authors.
2+
* Copyright 2006-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,12 +15,14 @@
1515
*/
1616
package org.springframework.batch.core;
1717

18+
import org.springframework.lang.Nullable;
1819

1920
/**
2021
* Listener interface for the lifecycle of a {@link Step}.
2122
*
2223
* @author Lucas Ward
2324
* @author Dave Syer
25+
* @author Mahmoud Ben Hassine
2426
*
2527
*/
2628
public interface StepExecutionListener extends StepListener {
@@ -44,7 +46,8 @@ public interface StepExecutionListener extends StepListener {
4446
*
4547
* @param stepExecution {@link StepExecution} instance.
4648
* @return an {@link ExitStatus} to combine with the normal value. Return
47-
* null to leave the old value unchanged.
49+
* {@code null} to leave the old value unchanged.
4850
*/
51+
@Nullable
4952
ExitStatus afterStep(StepExecution stepExecution);
5053
}

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/JobLocator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2007 the original author or authors.
2+
* Copyright 2006-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,12 +17,14 @@
1717

1818
import org.springframework.batch.core.Job;
1919
import org.springframework.batch.core.launch.NoSuchJobException;
20+
import org.springframework.lang.Nullable;
2021

2122
/**
2223
* A runtime service locator interface for retrieving job configurations by
2324
* <code>name</code>.
2425
*
2526
* @author Dave Syer
27+
* @author Mahmoud Ben Hassine
2628
*
2729
*/
2830
public interface JobLocator {
@@ -37,5 +39,5 @@ public interface JobLocator {
3739
* @throws NoSuchJobException if the required configuration can
3840
* not be found.
3941
*/
40-
Job getJob(String name) throws NoSuchJobException;
42+
Job getJob(@Nullable String name) throws NoSuchJobException;
4143
}

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/package-info.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
* Annotations and builder factories for java based configuration
33
*
44
* @author Michael Minella
5+
* @author Mahmoud Ben Hassine
56
*/
6-
package org.springframework.batch.core.configuration.annotation;
7+
@NonNullApi
8+
package org.springframework.batch.core.configuration.annotation;
9+
10+
import org.springframework.lang.NonNullApi;

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/package-info.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
* Interfaces for registration and location of job configurations.
33
*
44
* @author Michael Minella
5+
* @author Mahmoud Ben Hassine
56
*/
6-
package org.springframework.batch.core.configuration;
7+
@NonNullApi
8+
package org.springframework.batch.core.configuration;
9+
10+
import org.springframework.lang.NonNullApi;

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/DefaultJobLoader.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2013 the original author or authors.
2+
* Copyright 2006-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@
3535
import org.springframework.beans.factory.InitializingBean;
3636
import org.springframework.context.ApplicationContext;
3737
import org.springframework.context.ConfigurableApplicationContext;
38+
import org.springframework.lang.Nullable;
3839
import org.springframework.util.Assert;
3940

4041
/**
@@ -45,6 +46,7 @@
4546
*
4647
* @author Dave Syer
4748
* @author Stephane Nicoll
49+
* @author Mahmoud Ben Hassine
4850
*/
4951
public class DefaultJobLoader implements JobLoader, InitializingBean {
5052

@@ -77,9 +79,9 @@ public DefaultJobLoader(JobRegistry jobRegistry) {
7779
* Creates a job loader with the job and step registries provided.
7880
*
7981
* @param jobRegistry a {@link JobRegistry}
80-
* @param stepRegistry a {@link StepRegistry}
82+
* @param stepRegistry a {@link StepRegistry} (can be {@code null})
8183
*/
82-
public DefaultJobLoader(JobRegistry jobRegistry, StepRegistry stepRegistry) {
84+
public DefaultJobLoader(JobRegistry jobRegistry, @Nullable StepRegistry stepRegistry) {
8385
this.jobRegistry = jobRegistry;
8486
this.stepRegistry = stepRegistry;
8587
}

0 commit comments

Comments
 (0)