df
03/10/2025, 7:39 PMlastJobExecution
is clearly of type JobExecution?
Michael Krussel
03/10/2025, 7:59 PMgetLastJobExecution
?
Does this compile using gradle, sometimes the IDE reports false positive errors.df
03/10/2025, 8:07 PM@Nullable
JobExecution getLastJobExecution(String jobName, JobParameters jobParameters);
And the maven build fails with the same errorMichael Krussel
03/10/2025, 8:33 PMBatchStatus.FAILED
? Is that a mutable boolean variable or is it being compared to something under the tooltip?Michael Krussel
03/10/2025, 8:34 PMclass JobExecution(
val isSomethingICannotSee: Boolean
)
typealias JobParameters = String
const val IMPORT_ORDER_JOB_NAME = "name"
interface JobRepository {
fun getLastJobExecution(jobName: String, jobParameters: JobParameters): JobExecution?
}
lateinit var jobRepository: JobRepository
fun validate(jobParameters: JobParameters) {
val lastJobExecution: JobExecution? = jobRepository.getLastJobExecution(
IMPORT_ORDER_JOB_NAME,
jobParameters
)
val error = when {
lastJobExecution == null -> "Job does not exist"
lastJobExecution.isSomethingICannotSee -> "other error"
else -> null
}
}
Michael Krussel
03/10/2025, 8:34 PMJacob
03/11/2025, 3:35 AMdf
03/11/2025, 1:01 PMlastJobExecution?.someProperty == null
which worked fine.Michael Krussel
03/11/2025, 1:07 PMKlitos Kyriacou
03/11/2025, 1:07 PMlastJobExecution === null
- which seems unnecessarily longer than ==
but still shorter than your last workaround.Jacob
03/11/2025, 1:11 PMJacob
03/11/2025, 1:12 PMKlitos Kyriacou
03/11/2025, 1:28 PMequals(Any)
instead of equals(Any?)
, wouldn't ExitStatus
still inherit equals(Any?)
from its superclass Any
?Michael Krussel
03/11/2025, 1:36 PMnull
is part of the type system it doesn't change the function signatures on the JVM. So the function is overriding the function but not in a valid way since they are restricting the type of an input parameter. Kotlin probably wouldn't allow it, but since null is not part of the Java type system, Java cannot. So yes, Spring should annotate the override with Nullable, since they handle null and not handling null would be a contract violation. So Kotlin, knows if they call equals
they will get the one in ExitStatus
, and not the one in Any
, but Spring says they cannot pass null
into it, so the compiler is stuck saying the operation is illegal.