Skip to content

Commit c7aabeb

Browse files
committed
Add default implementation to Job#getName
Resolves #4966
1 parent 0056722 commit c7aabeb

File tree

1 file changed

+11
-2
lines changed
  • spring-batch-core/src/main/java/org/springframework/batch/core/job

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2022 the original author or authors.
2+
* Copyright 2006-2025 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.
@@ -28,9 +28,18 @@
2828
* @author Dave Syer
2929
* @author Mahmoud Ben Hassine
3030
*/
31+
@FunctionalInterface
3132
public interface Job {
3233

33-
String getName();
34+
/**
35+
* The name of the job. This is used to distinguish between different jobs and must be
36+
* unique within the job repository. If not explicitly set, the name will default to
37+
* the fully qualified class name.
38+
* @return the name of the job (never {@code null})
39+
*/
40+
default String getName() {
41+
return this.getClass().getName();
42+
}
3443

3544
/**
3645
* Flag to indicate if this job can be restarted, at least in principle.

0 commit comments

Comments
 (0)