From 0e7a444aba0f41b587a726e5c0dbd1c1dd6d23ca Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Tue, 18 Mar 2014 14:33:07 +0100 Subject: [PATCH] DATACMNS-468 - Removed obsolete generics on BeanWrapper. Some additional JavaDoc cleanups in BeanWrapper. --- .../MappingContextIsNewStrategyFactory.java | 2 +- .../data/mapping/model/BeanWrapper.java | 32 +++++++++---------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/springframework/data/mapping/context/MappingContextIsNewStrategyFactory.java b/src/main/java/org/springframework/data/mapping/context/MappingContextIsNewStrategyFactory.java index 0cbddf8f3..902662087 100644 --- a/src/main/java/org/springframework/data/mapping/context/MappingContextIsNewStrategyFactory.java +++ b/src/main/java/org/springframework/data/mapping/context/MappingContextIsNewStrategyFactory.java @@ -95,7 +95,7 @@ public class MappingContextIsNewStrategyFactory extends IsNewStrategyFactorySupp */ public boolean isNew(Object entity) { - BeanWrapper, Object> wrapper = BeanWrapper.create(entity, null); + BeanWrapper wrapper = BeanWrapper.create(entity, null); Object propertyValue = wrapper.getProperty(property); return decideIsNew(propertyValue); diff --git a/src/main/java/org/springframework/data/mapping/model/BeanWrapper.java b/src/main/java/org/springframework/data/mapping/model/BeanWrapper.java index f86576d35..464adb36a 100644 --- a/src/main/java/org/springframework/data/mapping/model/BeanWrapper.java +++ b/src/main/java/org/springframework/data/mapping/model/BeanWrapper.java @@ -16,11 +16,9 @@ package org.springframework.data.mapping.model; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.springframework.core.convert.ConversionService; -import org.springframework.data.mapping.PersistentEntity; import org.springframework.data.mapping.PersistentProperty; import org.springframework.util.Assert; import org.springframework.util.ReflectionUtils; @@ -30,7 +28,7 @@ import org.springframework.util.ReflectionUtils; * * @author Oliver Gierke */ -public class BeanWrapper, T> { +public class BeanWrapper { private final T bean; private final ConversionService conversionService; @@ -39,18 +37,15 @@ public class BeanWrapper, T> { * Creates a new {@link BeanWrapper} for the given bean instance and {@link ConversionService}. If * {@link ConversionService} is {@literal null} no property type conversion will take place. * - * @param * @param * @param bean must not be {@literal null}. * @param conversionService can be {@literal null}. * @return */ - public static , T> BeanWrapper create(T bean, - ConversionService conversionService) { + public static BeanWrapper create(T bean, ConversionService conversionService) { Assert.notNull(bean, "Wrapped instance must not be null!"); - - return new BeanWrapper(bean, conversionService); + return new BeanWrapper(bean, conversionService); } private BeanWrapper(T bean, ConversionService conversionService) { @@ -64,13 +59,13 @@ public class BeanWrapper, T> { * {@link ConversionService} is configured. * * @param property must not be {@literal null}. - * @param value - * @param fieldAccessOnly whether to only try accessing the field ({@literal true}) or try using the getter first. - * @throws IllegalAccessException - * @throws InvocationTargetException + * @param value can be {@literal null}. + * @throws MappingException in case an exception occurred when setting the property value. */ public void setProperty(PersistentProperty property, Object value) { + Assert.notNull(property, "PersistentProperty must not be null!"); + Method setter = property.getSetter(); try { @@ -98,7 +93,7 @@ public class BeanWrapper, T> { * Returns the value of the given {@link PersistentProperty} of the underlying bean instance. * * @param - * @param property + * @param property must not be {@literal null}. * @return */ public Object getProperty(PersistentProperty property) { @@ -110,11 +105,14 @@ public class BeanWrapper, T> { * * @param * @param property must not be {@literal null}. - * @param type + * @param type can be {@literal null}. * @return + * @throws MappingException in case an exception occured when accessing the property. */ public S getProperty(PersistentProperty property, Class type) { + Assert.notNull(property, "PersistentProperty must not be null!"); + try { Object obj = null; @@ -143,8 +141,8 @@ public class BeanWrapper, T> { /** * Converts the given source value if it is not assignable to the given target type. * - * @param source - * @param targetType + * @param source can be {@literal null}. + * @param targetType can be {@literal null}. * @return */ @SuppressWarnings("unchecked") @@ -163,7 +161,7 @@ public class BeanWrapper, T> { /** * Returns the underlying bean instance. * - * @return + * @return will never be {@literal null}. */ public T getBean() { return bean;