Remove package cycle between mapping and convert.
Remove accessor methods to obtain annotated converters on PersistentProperty. Closes #2576
This commit is contained in:
@@ -23,9 +23,6 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.data.convert.PropertyValueConverter;
|
||||
import org.springframework.data.convert.ValueConversionContext;
|
||||
import org.springframework.data.convert.ValueConverter;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -427,34 +424,4 @@ public interface PersistentProperty<P extends PersistentProperty<P>> {
|
||||
return getOwner().getPropertyAccessor(owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the {@link PropertyValueConverter converter type} to be used for reading and writing property values. Uses
|
||||
* the {@link ValueConverter} annotation and extracts its {@link ValueConverter#value() value} attribute.
|
||||
* <p>
|
||||
* Store implementations may override the default and resort to a more specific annotation type.
|
||||
*
|
||||
* @return {@literal null} if none defined. Check {@link #hasValueConverter()} to check if the annotation is present
|
||||
* at all.
|
||||
* @since 2.7
|
||||
*/
|
||||
@Nullable
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
default Class<? extends PropertyValueConverter<?, ?, ? extends ValueConversionContext<? extends PersistentProperty<?>>>> getValueConverterType() {
|
||||
|
||||
ValueConverter annotation = findAnnotation(ValueConverter.class);
|
||||
|
||||
return annotation == null ? null : (Class) annotation.value();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether a value converter is configured. Uses {@link ValueConverter} as annotation type.
|
||||
* <p>
|
||||
* Store implementations may override the default and resort to a more specific annotation type.
|
||||
*
|
||||
* @return {@literal true} if a value converter is configured.
|
||||
* @since 2.7
|
||||
*/
|
||||
default boolean hasValueConverter() {
|
||||
return isAnnotationPresent(ValueConverter.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,6 @@ import org.springframework.data.annotation.ReadOnlyProperty;
|
||||
import org.springframework.data.annotation.Reference;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.annotation.Version;
|
||||
import org.springframework.data.convert.PropertyValueConverter;
|
||||
import org.springframework.data.convert.ValueConversionContext;
|
||||
import org.springframework.data.convert.ValueConverter;
|
||||
import org.springframework.data.mapping.Association;
|
||||
import org.springframework.data.mapping.MappingException;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
@@ -285,17 +282,6 @@ public abstract class AnnotationBasedPersistentProperty<P extends PersistentProp
|
||||
return associationTargetType.getNullable();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Class<? extends PropertyValueConverter<?, ?, ? extends ValueConversionContext<? extends PersistentProperty<?>>>> getValueConverterType() {
|
||||
|
||||
return doFindAnnotation(ValueConverter.class) //
|
||||
.map(ValueConverter::value) //
|
||||
.map(Class.class::cast) //
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user