Migrate to JSpecify annotations for nullability constraints.
Closes #3170
This commit is contained in:
@@ -28,7 +28,7 @@ import java.lang.annotation.Target;
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Documented
|
||||
@Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, })
|
||||
@Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD, ElementType.METHOD })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface AccessType {
|
||||
|
||||
@@ -40,4 +40,5 @@ public @interface AccessType {
|
||||
enum Type {
|
||||
FIELD, PROPERTY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Core annotations being used by Spring Data.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.jspecify.annotations.NullMarked
|
||||
package org.springframework.data.annotation;
|
||||
|
||||
@@ -22,6 +22,8 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
@@ -29,7 +31,6 @@ import org.springframework.beans.factory.config.BeanReference;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.data.util.TypeScanner;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.aot;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.aop.SpringProxy;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
@@ -26,7 +28,6 @@ import org.springframework.core.DecoratingProxy;
|
||||
import org.springframework.data.domain.AuditorAware;
|
||||
import org.springframework.data.domain.ReactiveAuditorAware;
|
||||
import org.springframework.data.util.ReactiveWrappers;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
@@ -132,7 +134,7 @@ class DefaultAotContext implements AotContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> resolveType() {
|
||||
public @Nullable Class<?> resolveType() {
|
||||
return factory.getType(beanName, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.function.Supplier;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution;
|
||||
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor;
|
||||
@@ -30,7 +31,6 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.data.domain.ManagedTypes;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -48,9 +48,9 @@ public class ManagedTypesBeanFactoryInitializationAotProcessor implements BeanFa
|
||||
private static final Log logger = LogFactory.getLog(ManagedTypesBeanFactoryInitializationAotProcessor.class);
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@Contract("_ -> null")
|
||||
public BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableListableBeanFactory beanFactory) {
|
||||
public @Nullable BeanFactoryInitializationAotContribution processAheadOfTime(
|
||||
ConfigurableListableBeanFactory beanFactory) {
|
||||
|
||||
processManagedTypes(beanFactory);
|
||||
return null;
|
||||
@@ -82,12 +82,15 @@ public class ManagedTypesBeanFactoryInitializationAotProcessor implements BeanFa
|
||||
}
|
||||
|
||||
Object value = potentiallyWrapToIterable(supplier.get());
|
||||
String beanClassName = beanDefinition.getBeanClassName();
|
||||
|
||||
BeanDefinition beanDefinitionReplacement = newManagedTypeBeanDefinition(beanDefinition.getBeanClassName(),
|
||||
value);
|
||||
if (beanClassName != null) {
|
||||
|
||||
registry.removeBeanDefinition(beanName);
|
||||
registry.registerBeanDefinition(beanName, beanDefinitionReplacement);
|
||||
BeanDefinition beanDefinitionReplacement = newManagedTypeBeanDefinition(beanClassName, value);
|
||||
|
||||
registry.removeBeanDefinition(beanName);
|
||||
registry.registerBeanDefinition(beanName, beanDefinitionReplacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.aot.generate.GenerationContext;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
@@ -34,7 +36,6 @@ import org.springframework.data.domain.ManagedTypes;
|
||||
import org.springframework.data.util.QTypeContributor;
|
||||
import org.springframework.data.util.TypeContributor;
|
||||
import org.springframework.data.util.TypeUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -61,7 +62,7 @@ public class ManagedTypesBeanRegistrationAotProcessor implements BeanRegistratio
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
|
||||
public @Nullable BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
|
||||
|
||||
if (!isMatch(registeredBean.getBeanClass(), registeredBean.getBeanName())) {
|
||||
return null;
|
||||
|
||||
@@ -22,6 +22,8 @@ import java.util.function.BiConsumer;
|
||||
|
||||
import javax.lang.model.element.Modifier;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.aot.generate.AccessControl;
|
||||
import org.springframework.aot.generate.GeneratedMethod;
|
||||
import org.springframework.aot.generate.GenerationContext;
|
||||
@@ -41,7 +43,6 @@ import org.springframework.javapoet.MethodSpec.Builder;
|
||||
import org.springframework.javapoet.ParameterizedTypeName;
|
||||
import org.springframework.javapoet.TypeName;
|
||||
import org.springframework.javapoet.WildcardTypeName;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
* Support for registering the need for reflection, resources, java serialization and proxies at runtime for Ahead of
|
||||
* Time compilation.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.jspecify.annotations.NullMarked
|
||||
package org.springframework.data.aot;
|
||||
|
||||
@@ -18,8 +18,9 @@ package org.springframework.data.auditing;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to abstract the ways setting the auditing information can be implemented.
|
||||
|
||||
@@ -20,11 +20,11 @@ import java.util.Optional;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.log.LogMessage;
|
||||
import org.springframework.data.domain.Auditable;
|
||||
import org.springframework.data.mapping.context.PersistentEntities;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,8 @@ package org.springframework.data.auditing;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,13 +24,14 @@ import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.convert.Jsr310Converters;
|
||||
import org.springframework.data.domain.Auditable;
|
||||
import org.springframework.data.util.ReflectionUtils;
|
||||
import org.springframework.format.support.DefaultFormattingConversionService;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -115,7 +116,7 @@ class DefaultAuditableBeanWrapperFactory implements AuditableBeanWrapperFactory
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object setCreatedBy(@Nullable Object value) {
|
||||
public @Nullable Object setCreatedBy(@Nullable Object value) {
|
||||
|
||||
auditable.setCreatedBy(value);
|
||||
return value;
|
||||
@@ -130,7 +131,7 @@ class DefaultAuditableBeanWrapperFactory implements AuditableBeanWrapperFactory
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object setLastModifiedBy(Object value) {
|
||||
public @Nullable Object setLastModifiedBy(@Nullable Object value) {
|
||||
|
||||
auditable.setLastModifiedBy(value);
|
||||
|
||||
@@ -267,7 +268,7 @@ class DefaultAuditableBeanWrapperFactory implements AuditableBeanWrapperFactory
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object setCreatedBy(@Nullable Object value) {
|
||||
public @Nullable Object setCreatedBy(@Nullable Object value) {
|
||||
return setField(metadata.getCreatedByField(), value);
|
||||
}
|
||||
|
||||
@@ -277,7 +278,7 @@ class DefaultAuditableBeanWrapperFactory implements AuditableBeanWrapperFactory
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object setLastModifiedBy(@Nullable Object value) {
|
||||
public @Nullable Object setLastModifiedBy(@Nullable Object value) {
|
||||
return setField(metadata.getLastModifiedByField(), value);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
@@ -41,7 +43,6 @@ import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.data.mapping.context.PersistentEntities;
|
||||
import org.springframework.data.util.Lazy;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -195,7 +196,7 @@ public class MappingAuditableBeanWrapperFactory extends DefaultAuditableBeanWrap
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object setCreatedBy(Object value) {
|
||||
public @Nullable Object setCreatedBy(@Nullable Object value) {
|
||||
return setProperty(metadata.createdByPaths, value);
|
||||
}
|
||||
|
||||
@@ -205,7 +206,7 @@ public class MappingAuditableBeanWrapperFactory extends DefaultAuditableBeanWrap
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object setLastModifiedBy(@Nullable Object value) {
|
||||
public @Nullable Object setLastModifiedBy(@Nullable Object value) {
|
||||
return setProperty(metadata.lastModifiedByPaths, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ package org.springframework.data.auditing.config;
|
||||
|
||||
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.*;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.aop.framework.ProxyFactoryBean;
|
||||
import org.springframework.aop.target.LazyInitTargetSource;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
@@ -45,7 +47,7 @@ public class AuditingHandlerBeanDefinitionParser extends AbstractSingleBeanDefin
|
||||
private static final String AUDITOR_AWARE_REF = "auditor-aware-ref";
|
||||
|
||||
private final String mappingContextBeanName;
|
||||
private String resolvedBeanName;
|
||||
private @Nullable String resolvedBeanName;
|
||||
|
||||
/**
|
||||
* Creates a new {@link AuditingHandlerBeanDefinitionParser} to point to a {@link MappingContext} with the given bean
|
||||
@@ -65,7 +67,7 @@ public class AuditingHandlerBeanDefinitionParser extends AbstractSingleBeanDefin
|
||||
*
|
||||
* @return the resolvedBeanName
|
||||
*/
|
||||
public String getResolvedBeanName() {
|
||||
public @Nullable String getResolvedBeanName() {
|
||||
return resolvedBeanName;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Types to abstract authentication concepts.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.jspecify.annotations.NullMarked
|
||||
package org.springframework.data.auditing.config;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* General support for entity auditing.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.jspecify.annotations.NullMarked
|
||||
package org.springframework.data.auditing;
|
||||
|
||||
@@ -15,15 +15,17 @@
|
||||
*/
|
||||
package org.springframework.data.config;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,8 @@ import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.FatalBeanException;
|
||||
import org.springframework.beans.factory.parsing.ReaderContext;
|
||||
@@ -30,7 +32,6 @@ import org.springframework.core.type.filter.AspectJTypeFilter;
|
||||
import org.springframework.core.type.filter.AssignableTypeFilter;
|
||||
import org.springframework.core.type.filter.RegexPatternTypeFilter;
|
||||
import org.springframework.core.type.filter.TypeFilter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
@@ -101,7 +102,8 @@ public class TypeFilterParser {
|
||||
try {
|
||||
filters.add(createTypeFilter(childElement, classLoader));
|
||||
} catch (RuntimeException e) {
|
||||
readerContext.error(e.getMessage(), readerContext.extractSource(element), e.getCause());
|
||||
readerContext.error("Failed creating type filter: " + e.getMessage(), readerContext.extractSource(element),
|
||||
e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Basic support for creating custom Spring namespaces and JavaConfig.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.jspecify.annotations.NullMarked
|
||||
package org.springframework.data.config;
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.convert;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -28,7 +29,7 @@ import org.springframework.util.Assert;
|
||||
class AnnotatedPropertyValueConverterAccessor {
|
||||
|
||||
private final String name;
|
||||
private final ValueConverter annotation;
|
||||
private final @Nullable ValueConverter annotation;
|
||||
|
||||
public AnnotatedPropertyValueConverterAccessor(PersistentProperty<?> property) {
|
||||
|
||||
@@ -45,9 +46,8 @@ class AnnotatedPropertyValueConverterAccessor {
|
||||
* @return {@literal null} if none defined. Check {@link #hasValueConverter()} to check if the annotation is present
|
||||
* at all.
|
||||
*/
|
||||
@Nullable
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public Class<? extends PropertyValueConverter<?, ?, ? extends ValueConversionContext<? extends PersistentProperty<?>>>> getValueConverterType() {
|
||||
public @Nullable Class<? extends PropertyValueConverter<?, ?, ? extends ValueConversionContext<? extends PersistentProperty<?>>>> getValueConverterType() {
|
||||
return annotation != null ? (Class) annotation.value() : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,12 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.mapping.Alias;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -71,9 +72,8 @@ public class ConfigurableTypeInformationMapper implements TypeInformationMapper
|
||||
return typeToAlias.getOrDefault(type, Alias.NONE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TypeInformation<?> resolveTypeFrom(Alias alias) {
|
||||
public @Nullable TypeInformation<?> resolveTypeFrom(Alias alias) {
|
||||
return aliasToType.get(alias);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.GenericTypeResolver;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
@@ -38,7 +39,6 @@ import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
import org.springframework.data.util.CustomCollections;
|
||||
import org.springframework.data.util.Predicates;
|
||||
import org.springframework.data.util.Streamable;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -249,8 +249,7 @@ public class CustomConversions {
|
||||
* data store does not support property value conversions.
|
||||
* @see PropertyValueConversions
|
||||
*/
|
||||
@Nullable
|
||||
public PropertyValueConversions getPropertyValueConversions() {
|
||||
public @Nullable PropertyValueConversions getPropertyValueConversions() {
|
||||
return propertyValueConversions;
|
||||
}
|
||||
|
||||
@@ -447,8 +446,7 @@ public class CustomConversions {
|
||||
* @param targetType must not be {@literal null}.
|
||||
* @return the actual target type for the given {@code sourceType} and {@code targetType}.
|
||||
*/
|
||||
@Nullable
|
||||
private Class<?> getCustomReadTarget(Class<?> sourceType, Class<?> targetType) {
|
||||
private @Nullable Class<?> getCustomReadTarget(Class<?> sourceType, Class<?> targetType) {
|
||||
return customReadTargetTypes.computeIfAbsent(sourceType, targetType, getReadTarget);
|
||||
}
|
||||
|
||||
@@ -461,8 +459,7 @@ public class CustomConversions {
|
||||
* @param pairs must not be {@literal null}.
|
||||
* @return the base {@link Class type} for the (requested) {@link Class target type} if present.
|
||||
*/
|
||||
@Nullable
|
||||
private Class<?> getCustomTarget(Class<?> sourceType, @Nullable Class<?> targetType,
|
||||
private @Nullable Class<?> getCustomTarget(Class<?> sourceType, @Nullable Class<?> targetType,
|
||||
Collection<ConvertiblePair> pairs) {
|
||||
|
||||
if (targetType != null && pairs.contains(new ConvertiblePair(sourceType, targetType))) {
|
||||
@@ -505,8 +502,8 @@ public class CustomConversions {
|
||||
* @param mappingFunction must not be {@literal null}.
|
||||
* @return the optional target type.
|
||||
*/
|
||||
@Nullable
|
||||
public Class<?> computeIfAbsent(Class<?> sourceType, Function<ConvertiblePair, Class<?>> mappingFunction) {
|
||||
public @Nullable Class<?> computeIfAbsent(Class<?> sourceType,
|
||||
Function<ConvertiblePair, Class<?>> mappingFunction) {
|
||||
return computeIfAbsent(sourceType, AbsentTargetTypeMarker.class, mappingFunction);
|
||||
}
|
||||
|
||||
@@ -520,8 +517,7 @@ public class CustomConversions {
|
||||
* @param mappingFunction must not be {@literal null}.
|
||||
* @return the optional target type.
|
||||
*/
|
||||
@Nullable
|
||||
public Class<?> computeIfAbsent(Class<?> sourceType, Class<?> targetType,
|
||||
public @Nullable Class<?> computeIfAbsent(Class<?> sourceType, Class<?> targetType,
|
||||
Function<ConvertiblePair, Class<?>> mappingFunction) {
|
||||
|
||||
TargetTypes targetTypes = customReadTargetTypes.get(sourceType);
|
||||
@@ -575,8 +571,8 @@ public class CustomConversions {
|
||||
* @param mappingFunction must not be {@literal null}.
|
||||
* @return the optional target type.
|
||||
*/
|
||||
@Nullable
|
||||
public Class<?> computeIfAbsent(Class<?> targetType, Function<ConvertiblePair, Class<?>> mappingFunction) {
|
||||
public @Nullable Class<?> computeIfAbsent(Class<?> targetType,
|
||||
Function<ConvertiblePair, Class<?>> mappingFunction) {
|
||||
|
||||
Class<?> optionalTarget = conversionTargets.get(targetType);
|
||||
|
||||
@@ -927,7 +923,7 @@ public class CustomConversions {
|
||||
private final StoreConversions storeConversions;
|
||||
private final List<?> userConverters;
|
||||
private final Predicate<ConvertiblePair> converterRegistrationFilter;
|
||||
private final PropertyValueConversions propertyValueConversions;
|
||||
private final @Nullable PropertyValueConversions propertyValueConversions;
|
||||
|
||||
/**
|
||||
* Create a new ConverterConfiguration holding the given {@link StoreConversions} and user defined converters.
|
||||
@@ -1004,8 +1000,7 @@ public class CustomConversions {
|
||||
* @return the configured {@link PropertyValueConversions} if set, {@literal null} otherwise.
|
||||
* @since 2.7
|
||||
*/
|
||||
@Nullable
|
||||
public PropertyValueConversions getPropertyValueConversions() {
|
||||
public @Nullable PropertyValueConversions getPropertyValueConversions() {
|
||||
return this.propertyValueConversions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.convert.converter.GenericConverter;
|
||||
@@ -29,7 +31,6 @@ import org.springframework.data.convert.ConverterBuilder.ConverterAware;
|
||||
import org.springframework.data.convert.ConverterBuilder.ReadingConverterBuilder;
|
||||
import org.springframework.data.convert.ConverterBuilder.WritingConverterBuilder;
|
||||
import org.springframework.data.util.Optionals;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -111,10 +112,9 @@ record DefaultConverterBuilder<S, T> (ConvertiblePair convertiblePair,
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
public @Nullable Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
return function.apply((S) source);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,12 +23,13 @@ import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.data.mapping.Alias;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -106,9 +107,8 @@ public class DefaultTypeMapper<S> implements TypeMapper<S>, BeanClassLoaderAware
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TypeInformation<?> readType(S source) {
|
||||
public @Nullable TypeInformation<?> readType(S source) {
|
||||
|
||||
Assert.notNull(source, "Source object must not be null");
|
||||
|
||||
@@ -122,8 +122,7 @@ public class DefaultTypeMapper<S> implements TypeMapper<S>, BeanClassLoaderAware
|
||||
* @param alias
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
private TypeInformation<?> getFromCacheOrCreate(Alias alias) {
|
||||
private @Nullable TypeInformation<?> getFromCacheOrCreate(Alias alias) {
|
||||
return typeCache.computeIfAbsent(alias, getAlias).orElse(null);
|
||||
}
|
||||
|
||||
@@ -160,8 +159,7 @@ public class DefaultTypeMapper<S> implements TypeMapper<S>, BeanClassLoaderAware
|
||||
* @param source
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
private Class<?> getDefaultedTypeToBeUsed(S source) {
|
||||
private @Nullable Class<?> getDefaultedTypeToBeUsed(S source) {
|
||||
|
||||
TypeInformation<?> type = readType(source);
|
||||
type = type == null ? getFallbackTypeFor(source) : type;
|
||||
@@ -174,8 +172,7 @@ public class DefaultTypeMapper<S> implements TypeMapper<S>, BeanClassLoaderAware
|
||||
* @param source will never be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
protected TypeInformation<?> getFallbackTypeFor(S source) {
|
||||
protected @Nullable TypeInformation<?> getFallbackTypeFor(S source) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.convert;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.mapping.InstanceCreatorMetadata;
|
||||
import org.springframework.data.mapping.Parameter;
|
||||
@@ -28,7 +30,6 @@ import org.springframework.data.mapping.model.EntityInstantiator;
|
||||
import org.springframework.data.mapping.model.EntityInstantiators;
|
||||
import org.springframework.data.mapping.model.ParameterValueProvider;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -81,9 +82,8 @@ public class DtoInstantiatingConverter implements Converter<Object, Object> {
|
||||
Object dto = instantiator.createInstance(targetEntity, new ParameterValueProvider() {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
public Object getParameterValue(Parameter parameter) {
|
||||
public @Nullable Object getParameterValue(Parameter parameter) {
|
||||
|
||||
String name = parameter.getName();
|
||||
|
||||
|
||||
@@ -33,8 +33,9 @@ import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
/**
|
||||
* Helper class to register JSR-310 specific {@link Converter} implementations.
|
||||
|
||||
@@ -18,12 +18,13 @@ package org.springframework.data.convert;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.mapping.Alias;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -109,9 +110,8 @@ public class MappingContextTypeInformationMapper implements TypeInformationMappe
|
||||
return alias;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TypeInformation<?> resolveTypeFrom(Alias alias) {
|
||||
public @Nullable TypeInformation<?> resolveTypeFrom(Alias alias) {
|
||||
|
||||
for (Map.Entry<TypeInformation<?>, Alias> entry : typeMap.entrySet()) {
|
||||
if (entry.getValue().hasSamePresentValueAs(alias)) {
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.convert;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -74,8 +75,8 @@ public class PropertyValueConversionService {
|
||||
* @param <VCC> value conversion context type.
|
||||
* @return the value to be used in the domain model. Can be {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
public <P extends PersistentProperty<P>, VCC extends ValueConversionContext<P>> Object read(@Nullable Object value,
|
||||
public <P extends PersistentProperty<P>, VCC extends ValueConversionContext<P>> @Nullable Object read(
|
||||
@Nullable Object value,
|
||||
P property, VCC context) {
|
||||
|
||||
PropertyValueConverter<Object, Object, ValueConversionContext<P>> converter = conversions
|
||||
@@ -95,8 +96,8 @@ public class PropertyValueConversionService {
|
||||
* @param <VCC> value conversion context type.
|
||||
* @return the value to be written to the data store. Can be {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
public <P extends PersistentProperty<P>, VCC extends ValueConversionContext<P>> Object write(@Nullable Object value,
|
||||
public <P extends PersistentProperty<P>, VCC extends ValueConversionContext<P>> @Nullable Object write(
|
||||
@Nullable Object value,
|
||||
P property, VCC context) {
|
||||
|
||||
PropertyValueConverter<Object, Object, ValueConversionContext<P>> converter = conversions
|
||||
|
||||
@@ -17,8 +17,9 @@ package org.springframework.data.convert;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link PropertyValueConverter} provides a symmetric way of converting certain properties from domain to
|
||||
@@ -87,8 +88,7 @@ public interface PropertyValueConverter<DV, SV, C extends ValueConversionContext
|
||||
* never {@literal null}.
|
||||
* @return the converted value. Can be {@literal null}.
|
||||
*/
|
||||
@Nullable
|
||||
default SV writeNull(C context) {
|
||||
default @Nullable SV writeNull(C context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -102,15 +102,13 @@ public interface PropertyValueConverter<DV, SV, C extends ValueConversionContext
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object read(@Nullable Object value, ValueConversionContext context) {
|
||||
public @Nullable Object read(@Nullable Object value, ValueConversionContext context) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object write(@Nullable Object value, ValueConversionContext context) {
|
||||
public @Nullable Object write(@Nullable Object value, ValueConversionContext context) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -133,25 +131,23 @@ public interface PropertyValueConverter<DV, SV, C extends ValueConversionContext
|
||||
this.reader = reader;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public SV write(@Nullable DV value, ValueConversionContext<P> context) {
|
||||
public @Nullable SV write(@Nullable DV value, ValueConversionContext<P> context) {
|
||||
return writer.apply(value, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SV writeNull(ValueConversionContext<P> context) {
|
||||
public @Nullable SV writeNull(ValueConversionContext<P> context) {
|
||||
return writer.apply(null, context);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public DV read(@Nullable SV value, ValueConversionContext<P> context) {
|
||||
public @Nullable DV read(@Nullable SV value, ValueConversionContext<P> context) {
|
||||
return reader.apply(value, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DV readNull(ValueConversionContext<P> context) {
|
||||
public @Nullable DV readNull(ValueConversionContext<P> context) {
|
||||
return reader.apply(null, context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,13 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -57,10 +58,9 @@ final class PropertyValueConverterFactories {
|
||||
this.delegates = Collections.unmodifiableList(delegates);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <A, B, C extends ValueConversionContext<?>> PropertyValueConverter<A, B, C> getConverter(
|
||||
public <A, B, C extends ValueConversionContext<?>> @Nullable PropertyValueConverter<A, B, C> getConverter(
|
||||
PersistentProperty<?> property) {
|
||||
|
||||
return delegates.stream().map(it -> (PropertyValueConverter<A, B, C>) it.getConverter(property))
|
||||
@@ -68,7 +68,7 @@ final class PropertyValueConverterFactories {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S, T, C extends ValueConversionContext<?>> PropertyValueConverter<S, T, C> getConverter(
|
||||
public <S, T, C extends ValueConversionContext<?>> @Nullable PropertyValueConverter<S, T, C> getConverter(
|
||||
Class<? extends PropertyValueConverter<S, T, C>> converterType) {
|
||||
|
||||
return delegates.stream().filter(it -> it.getConverter(converterType) != null).findFirst()
|
||||
@@ -117,7 +117,7 @@ final class PropertyValueConverterFactories {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <DV, SV, C extends ValueConversionContext<?>> PropertyValueConverter<DV, SV, C> getConverter(
|
||||
public <DV, SV, C extends ValueConversionContext<?>> @Nullable PropertyValueConverter<DV, SV, C> getConverter(
|
||||
Class<? extends PropertyValueConverter<DV, SV, C>> converterType) {
|
||||
|
||||
Assert.notNull(converterType, "ConverterType must not be null");
|
||||
@@ -151,10 +151,9 @@ final class PropertyValueConverterFactories {
|
||||
this.converterRegistry = converterRegistry;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <DV, SV, C extends ValueConversionContext<?>> PropertyValueConverter<DV, SV, C> getConverter(
|
||||
public <DV, SV, C extends ValueConversionContext<?>> @Nullable PropertyValueConverter<DV, SV, C> getConverter(
|
||||
PersistentProperty<?> property) {
|
||||
|
||||
return (PropertyValueConverter<DV, SV, C>) converterRegistry.getConverter(property.getOwner().getType(),
|
||||
@@ -162,7 +161,7 @@ final class PropertyValueConverterFactories {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S, T, C extends ValueConversionContext<?>> PropertyValueConverter<S, T, C> getConverter(
|
||||
public <S, T, C extends ValueConversionContext<?>> @Nullable PropertyValueConverter<S, T, C> getConverter(
|
||||
Class<? extends PropertyValueConverter<S, T, C>> converterType) {
|
||||
|
||||
return null;
|
||||
@@ -189,10 +188,9 @@ final class PropertyValueConverterFactories {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public <DV, SV, C extends ValueConversionContext<?>> PropertyValueConverter<DV, SV, C> getConverter(
|
||||
public <DV, SV, C extends ValueConversionContext<?>> @Nullable PropertyValueConverter<DV, SV, C> getConverter(
|
||||
PersistentProperty<?> property) {
|
||||
|
||||
Optional<PropertyValueConverter<?, ?, ? extends ValueConversionContext<?>>> converter = cache.get(property);
|
||||
@@ -203,7 +201,7 @@ final class PropertyValueConverterFactories {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public <DV, SV, C extends ValueConversionContext<?>> PropertyValueConverter<DV, SV, C> getConverter(
|
||||
public <DV, SV, C extends ValueConversionContext<?>> @Nullable PropertyValueConverter<DV, SV, C> getConverter(
|
||||
Class<? extends PropertyValueConverter<DV, SV, C>> converterType) {
|
||||
|
||||
Optional<PropertyValueConverter<?, ?, ? extends ValueConversionContext<?>>> converter = cache.get(converterType);
|
||||
@@ -227,9 +225,9 @@ final class PropertyValueConverterFactories {
|
||||
return typeCache.get(type);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Contract("_, null -> null;_, !null -> !null")
|
||||
<S, T, C extends ValueConversionContext<?>> PropertyValueConverter<S, T, C> cache(PersistentProperty<?> property,
|
||||
<S, T, C extends ValueConversionContext<?>> @Nullable PropertyValueConverter<S, T, C> cache(
|
||||
PersistentProperty<?> property,
|
||||
@Nullable PropertyValueConverter<S, T, C> converter) {
|
||||
|
||||
perPropertyCache.putIfAbsent(property, Optional.ofNullable(converter));
|
||||
@@ -245,9 +243,8 @@ final class PropertyValueConverterFactories {
|
||||
return converter;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Contract("_, null -> null;_, !null -> !null")
|
||||
<S, T, C extends ValueConversionContext<?>> PropertyValueConverter<S, T, C> cache(Class<?> type,
|
||||
<S, T, C extends ValueConversionContext<?>> @Nullable PropertyValueConverter<S, T, C> cache(Class<?> type,
|
||||
@Nullable PropertyValueConverter<S, T, C> converter) {
|
||||
|
||||
typeCache.putIfAbsent(type, Optional.ofNullable(converter));
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.data.convert;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.data.convert.PropertyValueConverterFactories.BeanFactoryAwarePropertyValueConverterFactory;
|
||||
import org.springframework.data.convert.PropertyValueConverterFactories.CachingPropertyValueConverterFactory;
|
||||
@@ -25,7 +27,6 @@ import org.springframework.data.convert.PropertyValueConverterFactories.ChainedP
|
||||
import org.springframework.data.convert.PropertyValueConverterFactories.ConfiguredInstanceServingValueConverterFactory;
|
||||
import org.springframework.data.convert.PropertyValueConverterFactories.SimplePropertyConverterFactory;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -50,8 +51,7 @@ public interface PropertyValueConverterFactory {
|
||||
* @return can be {@literal null}.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
default <DV, SV, P extends ValueConversionContext<?>> PropertyValueConverter<DV, SV, P> getConverter(
|
||||
default <DV, SV, P extends ValueConversionContext<?>> @Nullable PropertyValueConverter<DV, SV, P> getConverter(
|
||||
PersistentProperty<?> property) {
|
||||
|
||||
AnnotatedPropertyValueConverterAccessor accessor = new AnnotatedPropertyValueConverterAccessor(property);
|
||||
@@ -72,8 +72,7 @@ public interface PropertyValueConverterFactory {
|
||||
* @param <C> value conversion context to use.
|
||||
* @return can be {@literal null}.
|
||||
*/
|
||||
@Nullable
|
||||
<DV, SV, C extends ValueConversionContext<?>> PropertyValueConverter<DV, SV, C> getConverter(
|
||||
<DV, SV, C extends ValueConversionContext<?>> @Nullable PropertyValueConverter<DV, SV, C> getConverter(
|
||||
Class<? extends PropertyValueConverter<DV, SV, C>> converterType);
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,10 +21,11 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.data.convert.PropertyValueConverterFactories.ChainedPropertyValueConverterFactory;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -60,12 +61,12 @@ public class SimplePropertyValueConversions implements PropertyValueConversions,
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public Object read(Object value, ValueConversionContext context) {
|
||||
public @Nullable Object read(Object value, ValueConversionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object write(Object value, ValueConversionContext context) {
|
||||
public @Nullable Object write(Object value, ValueConversionContext context) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -88,8 +89,7 @@ public class SimplePropertyValueConversions implements PropertyValueConversions,
|
||||
* @return the configured {@link PropertyValueConverterFactory}; can be {@literal null}.
|
||||
* @see PropertyValueConverterFactory
|
||||
*/
|
||||
@Nullable
|
||||
public PropertyValueConverterFactory getConverterFactory() {
|
||||
public @Nullable PropertyValueConverterFactory getConverterFactory() {
|
||||
return converterFactory;
|
||||
}
|
||||
|
||||
@@ -122,8 +122,7 @@ public class SimplePropertyValueConversions implements PropertyValueConversions,
|
||||
* @return the configured {@link ValueConverterRegistry}; can be {@literal null}.
|
||||
* @see ValueConverterRegistry
|
||||
*/
|
||||
@Nullable
|
||||
public ValueConverterRegistry<?> getValueConverterRegistry() {
|
||||
public @Nullable ValueConverterRegistry<?> getValueConverterRegistry() {
|
||||
return valueConverterRegistry;
|
||||
}
|
||||
|
||||
@@ -163,8 +162,7 @@ public class SimplePropertyValueConversions implements PropertyValueConversions,
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
private <DV, SV, P extends PersistentProperty<P>, D extends ValueConversionContext<P>> PropertyValueConverter<DV, SV, D> doGetConverter(
|
||||
private <DV, SV, P extends PersistentProperty<P>, D extends ValueConversionContext<P>> @Nullable PropertyValueConverter<DV, SV, D> doGetConverter(
|
||||
PersistentProperty<?> property) {
|
||||
|
||||
PropertyValueConverter<?, ?, ?> converter = converterCache.get(property);
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.data.convert;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -68,7 +70,7 @@ public class SimplePropertyValueConverterRegistry<P extends PersistentProperty<P
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <S, T> PropertyValueConverter<S, T, ? extends ValueConversionContext<P>> getConverter(Class<?> type,
|
||||
public <S, T> @Nullable PropertyValueConverter<S, T, ? extends ValueConversionContext<P>> getConverter(Class<?> type,
|
||||
String path) {
|
||||
|
||||
return (PropertyValueConverter<S, T, ? extends ValueConversionContext<P>>) converterRegistrationMap
|
||||
|
||||
@@ -19,10 +19,11 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.data.mapping.Alias;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
@@ -48,9 +49,8 @@ public class SimpleTypeInformationMapper implements TypeInformationMapper, BeanC
|
||||
* @return the type to be used for the given {@link String} representation or {@literal null} if nothing found or the
|
||||
* class cannot be loaded.
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public TypeInformation<?> resolveTypeFrom(Alias alias) {
|
||||
public @Nullable TypeInformation<?> resolveTypeFrom(Alias alias) {
|
||||
|
||||
String stringAlias = alias.mapTyped(String.class);
|
||||
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.convert;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.mapping.Alias;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to abstract the mapping from a type alias to the actual type.
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.convert;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to define strategies how to store type information in a store specific sink or source.
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.convert;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* The {@link ValueConversionContext} provides access to the store-specific {@link PersistentProperty} and allows to
|
||||
@@ -50,8 +51,7 @@ public interface ValueConversionContext<P extends PersistentProperty<P>> {
|
||||
* @see PersistentProperty#getTypeInformation()
|
||||
* @see #write(Object, TypeInformation)
|
||||
*/
|
||||
@Nullable
|
||||
default Object write(@Nullable Object value) {
|
||||
default @Nullable Object write(@Nullable Object value) {
|
||||
return write(value, getProperty().getTypeInformation());
|
||||
}
|
||||
|
||||
@@ -65,8 +65,7 @@ public interface ValueConversionContext<P extends PersistentProperty<P>> {
|
||||
* @see #write(Object, TypeInformation)
|
||||
* @see TypeInformation
|
||||
*/
|
||||
@Nullable
|
||||
default <T> T write(@Nullable Object value, Class<T> target) {
|
||||
default <T> @Nullable T write(@Nullable Object value, Class<T> target) {
|
||||
return write(value, TypeInformation.of(target));
|
||||
}
|
||||
|
||||
@@ -79,8 +78,7 @@ public interface ValueConversionContext<P extends PersistentProperty<P>> {
|
||||
* @throws IllegalStateException if value cannot be written as an instance of {@link TypeInformation type}.
|
||||
* @see TypeInformation
|
||||
*/
|
||||
@Nullable
|
||||
default <T> T write(@Nullable Object value, TypeInformation<T> target) {
|
||||
default <T> @Nullable T write(@Nullable Object value, TypeInformation<T> target) {
|
||||
|
||||
if (value == null || target.getType().isInstance(value)) {
|
||||
return target.getType().cast(value);
|
||||
@@ -100,8 +98,7 @@ public interface ValueConversionContext<P extends PersistentProperty<P>> {
|
||||
* @see PersistentProperty#getTypeInformation()
|
||||
* @see #read(Object, TypeInformation)
|
||||
*/
|
||||
@Nullable
|
||||
default Object read(@Nullable Object value) {
|
||||
default @Nullable Object read(@Nullable Object value) {
|
||||
return read(value, getProperty().getTypeInformation());
|
||||
}
|
||||
|
||||
@@ -115,8 +112,7 @@ public interface ValueConversionContext<P extends PersistentProperty<P>> {
|
||||
* @see #read(Object, TypeInformation)
|
||||
* @see TypeInformation
|
||||
*/
|
||||
@Nullable
|
||||
default <T> T read(@Nullable Object value, Class<T> target) {
|
||||
default <T> @Nullable T read(@Nullable Object value, Class<T> target) {
|
||||
return read(value, TypeInformation.of(target));
|
||||
}
|
||||
|
||||
@@ -129,8 +125,7 @@ public interface ValueConversionContext<P extends PersistentProperty<P>> {
|
||||
* @throws IllegalStateException if value cannot be read as an instance of {@link TypeInformation type}.
|
||||
* @see TypeInformation
|
||||
*/
|
||||
@Nullable
|
||||
default <T> T read(@Nullable Object value, TypeInformation<T> target) {
|
||||
default <T> @Nullable T read(@Nullable Object value, TypeInformation<T> target) {
|
||||
|
||||
if (value == null || target.getType().isInstance(value)) {
|
||||
return target.getType().cast(value);
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.convert;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A registry of {@link PersistentProperty property-specific} {@link PropertyValueConverter value converters}
|
||||
@@ -48,8 +49,8 @@ public interface ValueConverterRegistry<P extends PersistentProperty<P>> {
|
||||
* @param <SV> store-specific type.
|
||||
* @return {@literal null} if no converter present for the given type/path combination.
|
||||
*/
|
||||
@Nullable
|
||||
<DV, SV> PropertyValueConverter<DV, SV, ? extends ValueConversionContext<P>> getConverter(Class<?> type, String path);
|
||||
<DV, SV> @Nullable PropertyValueConverter<DV, SV, ? extends ValueConversionContext<P>> getConverter(Class<?> type,
|
||||
String path);
|
||||
|
||||
/**
|
||||
* Check if a converter is registered for the given type, path combination.
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
*
|
||||
* @see org.springframework.data.convert.EntityConverter
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.jspecify.annotations.NullMarked
|
||||
package org.springframework.data.convert;
|
||||
|
||||
@@ -17,8 +17,9 @@ package org.springframework.data.crossstore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface representing the set of changes in an entity.
|
||||
@@ -28,8 +29,7 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public interface ChangeSet {
|
||||
|
||||
@Nullable
|
||||
<T> T get(String key, Class<T> requiredClass, ConversionService cs);
|
||||
<T> @Nullable T get(String key, Class<T> requiredClass, ConversionService cs);
|
||||
|
||||
void set(String key, Object o);
|
||||
|
||||
|
||||
@@ -19,8 +19,9 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Simple ChangeSet implementation backed by a HashMap.
|
||||
@@ -56,14 +57,12 @@ public class HashMapChangeSet implements ChangeSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object removeProperty(String k) {
|
||||
public @Nullable Object removeProperty(String k) {
|
||||
return this.values.remove(k);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T get(String key, Class<T> requiredClass, ConversionService conversionService) {
|
||||
public <T> @Nullable T get(String key, Class<T> requiredClass, ConversionService conversionService) {
|
||||
|
||||
Object value = values.get(key);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Support for cross-store persistence.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.jspecify.annotations.NullMarked
|
||||
package org.springframework.data.crossstore;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.data.domain;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Interface for auditable entities. Allows storing and retrieving creation and modification information. The changing
|
||||
|
||||
@@ -22,9 +22,10 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.lang.CheckReturnValue;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -608,7 +609,7 @@ public interface ExampleMatcher {
|
||||
* @author Mark Paluch
|
||||
* @since 1.12
|
||||
*/
|
||||
class PropertySpecifier {
|
||||
static class PropertySpecifier {
|
||||
|
||||
private final String path;
|
||||
private final @Nullable StringMatcher stringMatcher;
|
||||
@@ -692,16 +693,14 @@ public interface ExampleMatcher {
|
||||
*
|
||||
* @return can be {@literal null}.
|
||||
*/
|
||||
@Nullable
|
||||
public StringMatcher getStringMatcher() {
|
||||
public @Nullable StringMatcher getStringMatcher() {
|
||||
return stringMatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@literal null} if not set.
|
||||
*/
|
||||
@Nullable
|
||||
public Boolean getIgnoreCase() {
|
||||
public @Nullable Boolean getIgnoreCase() {
|
||||
return ignoreCase;
|
||||
}
|
||||
|
||||
@@ -711,7 +710,7 @@ public interface ExampleMatcher {
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
public PropertyValueTransformer getPropertyValueTransformer() {
|
||||
return valueTransformer == null ? NoOpPropertyValueTransformer.INSTANCE : valueTransformer;
|
||||
return valueTransformer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -772,7 +771,7 @@ public interface ExampleMatcher {
|
||||
private final Map<String, PropertySpecifier> propertySpecifiers;
|
||||
|
||||
PropertySpecifiers() {
|
||||
this. propertySpecifiers = new LinkedHashMap<>();
|
||||
this.propertySpecifiers = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
PropertySpecifiers(PropertySpecifiers propertySpecifiers) {
|
||||
@@ -789,10 +788,21 @@ public interface ExampleMatcher {
|
||||
return propertySpecifiers.containsKey(path);
|
||||
}
|
||||
|
||||
public PropertySpecifier getForPath(String path) {
|
||||
public @Nullable PropertySpecifier getForPath(String path) {
|
||||
return propertySpecifiers.get(path);
|
||||
}
|
||||
|
||||
public PropertySpecifier getRequiredForPath(String path) {
|
||||
|
||||
PropertySpecifier specifier = getForPath(path);
|
||||
|
||||
if (specifier == null) {
|
||||
throw new IllegalArgumentException("No PropertySpecifier found for path '%s'".formatted(path));
|
||||
}
|
||||
|
||||
return specifier;
|
||||
}
|
||||
|
||||
public boolean hasValues() {
|
||||
return !propertySpecifiers.isEmpty();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.domain;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.domain.Limit.Limited;
|
||||
import org.springframework.data.domain.Limit.Unlimited;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link Limit} represents the maximum value up to which an operation should continue processing. It may be used for
|
||||
|
||||
@@ -18,7 +18,8 @@ package org.springframework.data.domain;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntFunction;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,8 @@ import java.io.Serial;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.io.Serial;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.lang.CheckReturnValue;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ public interface Pageable {
|
||||
*
|
||||
* @return the {@link Pageable} requesting the next {@link Page}.
|
||||
*/
|
||||
@Contract("_ -> new")
|
||||
@Contract("-> new")
|
||||
@CheckReturnValue
|
||||
Pageable next();
|
||||
|
||||
@@ -139,7 +139,7 @@ public interface Pageable {
|
||||
*
|
||||
* @return the previous {@link Pageable} or the first {@link Pageable} if the current one already is the first one.
|
||||
*/
|
||||
@Contract("_ -> new")
|
||||
@Contract("-> new")
|
||||
@CheckReturnValue
|
||||
Pageable previousOrFirst();
|
||||
|
||||
@@ -148,7 +148,7 @@ public interface Pageable {
|
||||
*
|
||||
* @return the {@link Pageable} requesting the first page.
|
||||
*/
|
||||
@Contract("_ -> new")
|
||||
@Contract("-> new")
|
||||
@CheckReturnValue
|
||||
Pageable first();
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.domain;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Simple interface for entities.
|
||||
|
||||
@@ -19,7 +19,8 @@ import java.util.Comparator;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.io.Serial;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link Slice}.
|
||||
|
||||
@@ -27,12 +27,13 @@ import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.util.MethodInvocationRecorder;
|
||||
import org.springframework.data.util.MethodInvocationRecorder.Recorded;
|
||||
import org.springframework.data.util.Streamable;
|
||||
import org.springframework.lang.CheckReturnValue;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -251,8 +252,7 @@ public class Sort implements Streamable<org.springframework.data.domain.Sort.Ord
|
||||
* @param property name of the property that should be sorted.
|
||||
* @return the sort {@link Order} or {@literal null} if the property is not sorted by.
|
||||
*/
|
||||
@Nullable
|
||||
public Order getOrderFor(String property) {
|
||||
public @Nullable Order getOrderFor(String property) {
|
||||
|
||||
for (Order order : this) {
|
||||
if (order.getProperty().equals(property)) {
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.domain;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -188,13 +189,12 @@ class TypedExampleMatcher implements ExampleMatcher {
|
||||
private PropertySpecifier getOrCreatePropertySpecifier(String propertyPath, PropertySpecifiers propertySpecifiers) {
|
||||
|
||||
if (propertySpecifiers.hasSpecifierForPath(propertyPath)) {
|
||||
return propertySpecifiers.getForPath(propertyPath);
|
||||
return propertySpecifiers.getRequiredForPath(propertyPath);
|
||||
}
|
||||
|
||||
return new PropertySpecifier(propertyPath);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object o) {
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.domain;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* {@link Pageable} implementation to represent the absence of pagination information.
|
||||
|
||||
@@ -21,9 +21,8 @@ import java.util.function.Function;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
|
||||
@@ -17,11 +17,12 @@ package org.springframework.data.domain.jaxb;
|
||||
|
||||
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Order;
|
||||
import org.springframework.data.domain.jaxb.SpringDataJaxb.OrderDto;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* XmlAdapter to convert {@link Order} instances into {@link OrderDto}s and vice versa.
|
||||
@@ -32,9 +33,8 @@ public class OrderAdapter extends XmlAdapter<OrderDto, Order> {
|
||||
|
||||
public static final OrderAdapter INSTANCE = new OrderAdapter();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public OrderDto marshal(@Nullable Order order) {
|
||||
public @Nullable OrderDto marshal(@Nullable Order order) {
|
||||
|
||||
if (order == null) {
|
||||
return null;
|
||||
@@ -46,10 +46,9 @@ public class OrderAdapter extends XmlAdapter<OrderDto, Order> {
|
||||
return dto;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Contract("null -> null")
|
||||
@Override
|
||||
public Order unmarshal(@Nullable OrderDto source) {
|
||||
public @Nullable Order unmarshal(@Nullable OrderDto source) {
|
||||
|
||||
if (source == null) {
|
||||
return null;
|
||||
|
||||
@@ -20,11 +20,12 @@ import jakarta.xml.bind.annotation.adapters.XmlAdapter;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.jaxb.SpringDataJaxb.PageDto;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link XmlAdapter} to convert {@link Page} instances into {@link PageDto} instances and vice versa.
|
||||
@@ -33,10 +34,9 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class PageAdapter extends XmlAdapter<PageDto, Page<Object>> {
|
||||
|
||||
@Nullable
|
||||
@Contract("null -> null; !null -> !null")
|
||||
@Override
|
||||
public PageDto marshal(@Nullable Page<Object> source) {
|
||||
public @Nullable PageDto marshal(@Nullable Page<Object> source) {
|
||||
|
||||
if (source == null) {
|
||||
return null;
|
||||
@@ -49,10 +49,9 @@ public class PageAdapter extends XmlAdapter<PageDto, Page<Object>> {
|
||||
return dto;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Contract("_ -> null")
|
||||
@Override
|
||||
public Page<Object> unmarshal(@Nullable PageDto v) {
|
||||
public @Nullable Page<Object> unmarshal(@Nullable PageDto v) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,13 @@ import jakarta.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.jaxb.SpringDataJaxb.PageRequestDto;
|
||||
import org.springframework.data.domain.jaxb.SpringDataJaxb.SortDto;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link XmlAdapter} to convert {@link Pageable} instances int a {@link PageRequestDto} and vice versa.
|
||||
@@ -34,9 +35,8 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
class PageableAdapter extends XmlAdapter<PageRequestDto, Pageable> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PageRequestDto marshal(@Nullable Pageable request) {
|
||||
public @Nullable PageRequestDto marshal(@Nullable Pageable request) {
|
||||
|
||||
if (request == null) {
|
||||
return null;
|
||||
|
||||
@@ -17,11 +17,12 @@ package org.springframework.data.domain.jaxb;
|
||||
|
||||
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.jaxb.SpringDataJaxb.SortDto;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link XmlAdapter} to convert {@link Sort} instances into {@link SortDto} instances and vice versa.
|
||||
@@ -32,10 +33,9 @@ public class SortAdapter extends XmlAdapter<SortDto, Sort> {
|
||||
|
||||
public static final SortAdapter INSTANCE = new SortAdapter();
|
||||
|
||||
@Nullable
|
||||
@Contract("null -> null; !null -> !null")
|
||||
@Override
|
||||
public SortDto marshal(@Nullable Sort source) {
|
||||
public @Nullable SortDto marshal(@Nullable Sort source) {
|
||||
|
||||
if (source == null) {
|
||||
return null;
|
||||
|
||||
@@ -29,6 +29,8 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -36,7 +38,6 @@ import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.data.domain.Sort.Order;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
@XmlJavaTypeAdapter(value = org.springframework.data.domain.jaxb.PageableAdapter.class, type = Pageable.class),
|
||||
@XmlJavaTypeAdapter(value = org.springframework.data.domain.jaxb.SortAdapter.class, type = Sort.class),
|
||||
@XmlJavaTypeAdapter(value = org.springframework.data.domain.jaxb.PageAdapter.class, type = Page.class) })
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.jspecify.annotations.NullMarked
|
||||
package org.springframework.data.domain.jaxb;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlNs;
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
*
|
||||
* @see org.springframework.data.repository.Repository
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.jspecify.annotations.NullMarked
|
||||
package org.springframework.data.domain;
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.data.expression;
|
||||
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Default {@link ValueEvaluationContext}.
|
||||
@@ -25,7 +24,7 @@ import org.springframework.lang.Nullable;
|
||||
* @author Mark Paluch
|
||||
* @since 3.3
|
||||
*/
|
||||
record DefaultValueEvaluationContext(@Nullable Environment environment,
|
||||
record DefaultValueEvaluationContext(Environment environment,
|
||||
EvaluationContext evaluationContext) implements ValueEvaluationContext {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.expression;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.spel.ExpressionDependencies;
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.expression.Expression;
|
||||
@@ -44,14 +46,14 @@ record ExpressionExpression(Expression expression, ExpressionDependencies depend
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evaluate(ValueEvaluationContext context) {
|
||||
public @Nullable Object evaluate(ValueEvaluationContext context) {
|
||||
|
||||
EvaluationContext evaluationContext = context.getEvaluationContext();
|
||||
return evaluationContext != null ? expression.getValue(evaluationContext) : expression.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getValueType(ValueEvaluationContext context) {
|
||||
public @Nullable Class<?> getValueType(ValueEvaluationContext context) {
|
||||
|
||||
EvaluationContext evaluationContext = context.getEvaluationContext();
|
||||
return evaluationContext != null ? expression.getValueType(evaluationContext) : expression.getValueType();
|
||||
|
||||
@@ -38,6 +38,7 @@ record PlaceholderExpression(String expression) implements ValueExpression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullAway")
|
||||
public String evaluate(ValueEvaluationContext context) {
|
||||
|
||||
Environment environment = context.getEnvironment();
|
||||
|
||||
@@ -17,8 +17,9 @@ package org.springframework.data.expression;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.spel.ExpressionDependencies;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Reactive extension to {@link ValueEvaluationContext} for obtaining a {@link ValueEvaluationContext} that participates
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.data.expression;
|
||||
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Expressions are executed in an evaluation context. It is in this context that references are resolved when
|
||||
@@ -36,24 +35,22 @@ public interface ValueEvaluationContext {
|
||||
* @param evaluationContext
|
||||
* @return a new {@link ValueEvaluationContext} for the given environment and evaluation context.
|
||||
*/
|
||||
static ValueEvaluationContext of(@Nullable Environment environment, EvaluationContext evaluationContext) {
|
||||
static ValueEvaluationContext of(Environment environment, EvaluationContext evaluationContext) {
|
||||
return new DefaultValueEvaluationContext(environment, evaluationContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Environment} if provided.
|
||||
*
|
||||
* @return the {@link Environment} or {@literal null}.
|
||||
* @return the {@link Environment}.
|
||||
*/
|
||||
@Nullable
|
||||
Environment getEnvironment();
|
||||
|
||||
/**
|
||||
* Returns the {@link EvaluationContext} if provided.
|
||||
*
|
||||
* @return the {@link EvaluationContext} or {@literal null} if not set.
|
||||
* @return the {@link EvaluationContext}.
|
||||
*/
|
||||
@Nullable
|
||||
EvaluationContext getEvaluationContext();
|
||||
|
||||
/**
|
||||
@@ -62,7 +59,10 @@ public interface ValueEvaluationContext {
|
||||
*
|
||||
* @return the {@link EvaluationContext}.
|
||||
* @since 3.4
|
||||
* @deprecated since 4.0, EvaluationContext is always provided.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("ConstantValue")
|
||||
default EvaluationContext getRequiredEvaluationContext() {
|
||||
|
||||
EvaluationContext evaluationContext = getEvaluationContext();
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.expression;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.spel.ExpressionDependencies;
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* SPI to provide to access a centrally defined potentially shared {@link ValueEvaluationContext}.
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.expression;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.spel.ExpressionDependencies;
|
||||
import org.springframework.expression.EvaluationException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* An expression capable of evaluating itself against context objects. Encapsulates the details of a previously parsed
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Value Expression implementation.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.jspecify.annotations.NullMarked
|
||||
package org.springframework.data.expression;
|
||||
|
||||
@@ -17,7 +17,8 @@ package org.springframework.data.geo;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
|
||||
@@ -17,8 +17,9 @@ package org.springframework.data.geo;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.annotation.PersistenceCreator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
|
||||
@@ -18,11 +18,12 @@ package org.springframework.data.geo;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.domain.Range;
|
||||
import org.springframework.data.domain.Range.Bound;
|
||||
import org.springframework.lang.CheckReturnValue;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
|
||||
@@ -17,10 +17,11 @@ package org.springframework.data.geo;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,8 @@ package org.springframework.data.geo;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
|
||||
@@ -22,8 +22,9 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.annotation.PersistenceCreator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -19,8 +19,9 @@ import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.annotation.PersistenceCreator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
|
||||
@@ -23,8 +23,9 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.annotation.PersistenceCreator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -22,13 +22,14 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.geo.Distance;
|
||||
import org.springframework.data.geo.Metric;
|
||||
import org.springframework.data.geo.Metrics;
|
||||
import org.springframework.format.Formatter;
|
||||
import org.springframework.lang.Contract;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -59,9 +60,8 @@ public enum DistanceFormatter implements Converter<String, Distance>, Formatter<
|
||||
}
|
||||
|
||||
@Contract("null -> null; !null -> !null")
|
||||
@Nullable
|
||||
@Override
|
||||
public final Distance convert(@Nullable String source) {
|
||||
public final @Nullable Distance convert(@Nullable String source) {
|
||||
return source == null ? null : doConvert(source.trim().toLowerCase(Locale.US));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,13 @@ package org.springframework.data.geo.format;
|
||||
import java.text.ParseException;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.convert.converter.GenericConverter.ConvertiblePair;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.format.Formatter;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Converter to parse two comma-separated doubles into a {@link Point}.
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
* @author Oliver Gierke
|
||||
* @since 1.8
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.jspecify.annotations.NullMarked
|
||||
package org.springframework.data.geo.format;
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
* @author Oliver Gierke
|
||||
* @since 1.8
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.jspecify.annotations.NullMarked
|
||||
package org.springframework.data.geo;
|
||||
|
||||
@@ -20,7 +20,8 @@ import static org.springframework.data.util.Optionals.*;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Basic interfaces and value objects for histography API.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.jspecify.annotations.NullMarked
|
||||
package org.springframework.data.history;
|
||||
|
||||
@@ -22,8 +22,9 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.mapping.AccessOptions.SetOptions.SetNulls;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -34,6 +35,7 @@ import org.springframework.util.Assert;
|
||||
* @author Oliver Drotbohm
|
||||
* @since 2.3
|
||||
*/
|
||||
@SuppressWarnings("NullAway")
|
||||
public class AccessOptions {
|
||||
|
||||
/**
|
||||
@@ -64,10 +66,11 @@ public class AccessOptions {
|
||||
|
||||
private static final GetOptions DEFAULT = new GetOptions(new HashMap<>(), GetNulls.REJECT);
|
||||
|
||||
private final Map<PersistentProperty<?>, Function<Object, Object>> handlers;
|
||||
private final Map<PersistentProperty<?>, Function<@Nullable Object, @Nullable Object>> handlers;
|
||||
private final GetNulls nullValues;
|
||||
|
||||
public GetOptions(Map<PersistentProperty<?>, Function<Object, Object>> handlers, GetNulls nullValues) {
|
||||
public GetOptions(Map<PersistentProperty<?>, Function<@Nullable Object, @Nullable Object>> handlers,
|
||||
GetNulls nullValues) {
|
||||
|
||||
this.handlers = handlers;
|
||||
this.nullValues = nullValues;
|
||||
@@ -110,12 +113,13 @@ public class AccessOptions {
|
||||
* @param handler must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
public GetOptions registerHandler(PersistentProperty<?> property, Function<Object, Object> handler) {
|
||||
public GetOptions registerHandler(PersistentProperty<?> property,
|
||||
Function<@Nullable Object, @Nullable Object> handler) {
|
||||
|
||||
Assert.notNull(property, "Property must not be null");
|
||||
Assert.notNull(handler, "Handler must not be null");
|
||||
|
||||
Map<PersistentProperty<?>, Function<Object, Object>> newHandlers = new HashMap<>(handlers);
|
||||
Map<PersistentProperty<?>, Function<@Nullable Object, @Nullable Object>> newHandlers = new HashMap<>(handlers);
|
||||
newHandlers.put(property, handler);
|
||||
|
||||
return new GetOptions(newHandlers, nullValues);
|
||||
@@ -130,7 +134,7 @@ public class AccessOptions {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public GetOptions registerCollectionHandler(PersistentProperty<?> property,
|
||||
Function<? super Collection<?>, Object> handler) {
|
||||
Function<? super Collection<?>, @Nullable Object> handler) {
|
||||
return registerHandler(property, Collection.class, (Function<Object, Object>) handler);
|
||||
}
|
||||
|
||||
@@ -142,7 +146,8 @@ public class AccessOptions {
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public GetOptions registerListHandler(PersistentProperty<?> property, Function<? super List<?>, Object> handler) {
|
||||
public GetOptions registerListHandler(PersistentProperty<?> property,
|
||||
Function<? super List<?>, @Nullable Object> handler) {
|
||||
return registerHandler(property, List.class, (Function<Object, Object>) handler);
|
||||
}
|
||||
|
||||
@@ -154,7 +159,8 @@ public class AccessOptions {
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public GetOptions registerSetHandler(PersistentProperty<?> property, Function<? super Set<?>, Object> handler) {
|
||||
public GetOptions registerSetHandler(PersistentProperty<?> property,
|
||||
Function<? super Set<?>, @Nullable Object> handler) {
|
||||
return registerHandler(property, Set.class, (Function<Object, Object>) handler);
|
||||
}
|
||||
|
||||
@@ -166,7 +172,8 @@ public class AccessOptions {
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public GetOptions registerMapHandler(PersistentProperty<?> property, Function<? super Map<?, ?>, Object> handler) {
|
||||
public GetOptions registerMapHandler(PersistentProperty<?> property,
|
||||
Function<? super Map<?, ?>, @Nullable Object> handler) {
|
||||
return registerHandler(property, Map.class, (Function<Object, Object>) handler);
|
||||
}
|
||||
|
||||
@@ -201,7 +208,7 @@ public class AccessOptions {
|
||||
@Nullable
|
||||
Object postProcess(PersistentProperty<?> property, @Nullable Object value) {
|
||||
|
||||
Function<Object, Object> handler = handlers.get(property);
|
||||
Function<@Nullable Object, @Nullable Object> handler = handlers.get(property);
|
||||
|
||||
return handler == null ? value : handler.apply(value);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ package org.springframework.data.mapping;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -87,6 +88,7 @@ public final class Alias {
|
||||
* @param other must not be {@literal null}.
|
||||
* @return {@literal true} if this value is present but different from the {@code other} value.
|
||||
*/
|
||||
@SuppressWarnings("NullAway")
|
||||
public boolean isPresentButDifferent(Alias other) {
|
||||
|
||||
Assert.notNull(other, "Other alias must not be null");
|
||||
@@ -100,8 +102,9 @@ public final class Alias {
|
||||
* @param that the other value, may be {@literal null}.
|
||||
* @return {@literal true} if this alias has a value and it equals to {@code that}.
|
||||
*/
|
||||
@SuppressWarnings("NullAway")
|
||||
public boolean hasValue(Object that) {
|
||||
return value != null && value.equals(that);
|
||||
return isPresent() && value.equals(that);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,6 +113,7 @@ public final class Alias {
|
||||
* @param other the other {@link Alias}
|
||||
* @return {@literal true} if there's an alias value present and its equal to the one in the given {@link Alias}.
|
||||
*/
|
||||
@SuppressWarnings("NullAway")
|
||||
public boolean hasSamePresentValueAs(Alias other) {
|
||||
return isPresent() && value.equals(other.value);
|
||||
}
|
||||
@@ -185,6 +189,7 @@ public final class Alias {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullAway")
|
||||
public String toString() {
|
||||
return isPresent() ? value.toString() : "NONE";
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.mapping;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Value object to capture {@link Association}s.
|
||||
@@ -44,8 +44,7 @@ public class Association<P extends PersistentProperty<P>> {
|
||||
return inverse;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public P getObverse() {
|
||||
public @Nullable P getObverse() {
|
||||
return obverse;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.mapping;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Interface for a component allowing the access of identifier values.
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.mapping;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Jon Brisbin
|
||||
|
||||
@@ -18,11 +18,12 @@ package org.springframework.data.mapping;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.annotation.MergedAnnotations;
|
||||
import org.springframework.data.util.Lazy;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -81,8 +82,7 @@ public class Parameter<T, P extends PersistentProperty<P>> {
|
||||
this.hasExpression = Lazy.of(() -> StringUtils.hasText(getValueExpression()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getValue(MergedAnnotations annotations) {
|
||||
private static @Nullable String getValue(MergedAnnotations annotations) {
|
||||
|
||||
return annotations.get(Value.class) //
|
||||
.getValue("value", String.class) //
|
||||
@@ -96,8 +96,7 @@ public class Parameter<T, P extends PersistentProperty<P>> {
|
||||
* @return the name of the parameter.
|
||||
* @see org.springframework.core.ParameterNameDiscoverer
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
public @Nullable String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -184,7 +183,7 @@ public class Parameter<T, P extends PersistentProperty<P>> {
|
||||
* @return the expression to be used when looking up a source data structure.
|
||||
* @since 3.3
|
||||
*/
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
@SuppressWarnings({ "DataFlowIssue", "NullAway" })
|
||||
public String getRequiredValueExpression() {
|
||||
|
||||
if (!hasValueExpression()) {
|
||||
|
||||
@@ -18,9 +18,10 @@ package org.springframework.data.mapping;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.annotation.Immutable;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -170,8 +171,7 @@ public interface PersistentEntity<T, P extends PersistentProperty<P>> extends It
|
||||
* @return {@literal null} if no property found with given annotation type.
|
||||
* @since 1.8
|
||||
*/
|
||||
@Nullable
|
||||
default P getPersistentProperty(Class<? extends Annotation> annotationType) {
|
||||
default @Nullable P getPersistentProperty(Class<? extends Annotation> annotationType) {
|
||||
|
||||
Iterator<P> it = getPersistentProperties(annotationType).iterator();
|
||||
return it.hasNext() ? it.next() : null;
|
||||
@@ -279,8 +279,7 @@ public interface PersistentEntity<T, P extends PersistentProperty<P>> extends It
|
||||
* @return {@literal null} if not found.
|
||||
* @since 1.8
|
||||
*/
|
||||
@Nullable
|
||||
<A extends Annotation> A findAnnotation(Class<A> annotationType);
|
||||
<A extends Annotation> @Nullable A findAnnotation(Class<A> annotationType);
|
||||
|
||||
/**
|
||||
* Returns the required annotation of the given type on the {@link PersistentEntity}.
|
||||
|
||||
@@ -21,10 +21,11 @@ import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.mapping;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Domain service to allow accessing and setting {@link PersistentProperty}s of an entity. Usually obtained through
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.mapping;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.util.Streamable;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Abstraction of a path of {@link PersistentProperty}s.
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.mapping;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.mapping.AccessOptions.GetOptions;
|
||||
import org.springframework.data.mapping.AccessOptions.SetOptions;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Extension of {@link PersistentPropertyAccessor} that is also able to obtain and set values for
|
||||
|
||||
@@ -26,9 +26,10 @@ import java.util.Stack;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.util.Streamable;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -102,8 +103,7 @@ public class PropertyPath implements Streamable<PropertyPath> {
|
||||
: this.typeInformation.getRequiredActualType();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Property lookupProperty(TypeInformation<?> owningType, String name) {
|
||||
private static @Nullable Property lookupProperty(TypeInformation<?> owningType, String name) {
|
||||
|
||||
TypeInformation<?> propertyType = owningType.getProperty(name);
|
||||
|
||||
@@ -185,8 +185,7 @@ public class PropertyPath implements Streamable<PropertyPath> {
|
||||
* @return the next nested {@link PropertyPath} or {@literal null} if no nested {@link PropertyPath} available.
|
||||
* @see #hasNext()
|
||||
*/
|
||||
@Nullable
|
||||
public PropertyPath next() {
|
||||
public @Nullable PropertyPath next() {
|
||||
return next;
|
||||
}
|
||||
|
||||
@@ -268,8 +267,7 @@ public class PropertyPath implements Streamable<PropertyPath> {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public PropertyPath next() {
|
||||
public @Nullable PropertyPath next() {
|
||||
|
||||
PropertyPath result = current;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user