I've been looking around other questions and I still don't understand what's going on here. I have this class:
package com.test.service.database.converter;
import com.test.service.database.dao.DocumentType;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import java.util.Optional;
@Component
public class DocumentStringConverter implements Converter<DocumentType, String> {
@Override
public String convert(DocumentType documentType) {
return Optional.ofNullable(documentType).map(DocumentType::type).orElse(null);
}
}
Which implements this Spring interface:
package org.springframework.core.convert.converter;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@FunctionalInterface
public interface Converter<S, T> {
@Nullable
T convert(S source);
default <U> Converter<S, U> andThen(Converter<? super T, ? extends U> after) {
Assert.notNull(after, "After Converter must not be null");
return (S s) -> {
T initialResult = convert(s);
return (initialResult != null ? after.convert(initialResult) : null);
};
}
}
And IntelliJ gives a warning on the param in
public String convert(DocumentType documentType) {
that states
Not annotated parameter overrides @NonNullApi parameter
documentType – the source object to convert, which must be an instance of S (never null)
Why is this? What does it mean, since Converter is annotated with @Nullable
? And how do I solve this warning?