Mostly fixing IDE warnings and complainings about type safety issues

This commit is contained in:
Jon Brisbin
2011-03-14 16:58:08 -05:00
committed by J. Brisbin
parent 1f9af56158
commit 69d007c2b8
11 changed files with 44 additions and 30 deletions

View File

@@ -17,7 +17,6 @@
package org.springframework.data.mapping;
import org.springframework.data.mapping.model.Association;
import org.springframework.data.mapping.model.PersistentProperty;
/**
* @author Jon Brisbin <jbrisbin@vmware.com>

View File

@@ -29,7 +29,6 @@ import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.annotation.Annotation;
import java.lang.reflect.*;
import java.math.BigInteger;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -60,7 +59,6 @@ public class BasicMappingConfigurationBuilder implements MappingConfigurationBui
return false;
}
@SuppressWarnings({"unchecked"})
@Override
public <T> PersistentEntity<T> createPersistentEntity(Class<T> type, MappingContext mappingContext) throws MappingConfigurationException {
return new BasicPersistentEntity<T>(mappingContext, type);
@@ -74,10 +72,9 @@ public class BasicMappingConfigurationBuilder implements MappingConfigurationBui
return true;
}
@SuppressWarnings({"unchecked"})
@Override
public PersistentProperty<?> createPersistentProperty(Field field, PropertyDescriptor descriptor) throws MappingConfigurationException {
return new BasicPersistentProperty(field.getName(), field.getType(), field, descriptor);
public <T> PersistentProperty<T> createPersistentProperty(Field field, PropertyDescriptor descriptor, Class<T> type) throws MappingConfigurationException {
return new BasicPersistentProperty<T>(field.getName(), type, field, descriptor);
}
@SuppressWarnings({"unchecked"})
@@ -112,7 +109,8 @@ public class BasicMappingConfigurationBuilder implements MappingConfigurationBui
}
} else {
if (paramTypes[i] instanceof TypeVariable) {
Type[] bounds = ((TypeVariable) paramTypes[i]).getBounds();
@SuppressWarnings("rawtypes")
Type[] bounds = ((TypeVariable) paramTypes[i]).getBounds();
if (bounds.length > 0) {
targetType = (Class<?>) bounds[0];
}

View File

@@ -101,7 +101,7 @@ public class BasicMappingContext implements MappingContext, InitializingBean {
PropertyDescriptor descriptor = descriptors.get(field.getName());
if (builder.isPersistentProperty(field, descriptor)) {
ReflectionUtils.makeAccessible(field);
PersistentProperty<?> property = builder.createPersistentProperty(field, descriptor);
PersistentProperty<?> property = builder.createPersistentProperty(field, descriptor, field.getType());
property.setOwner(entity);
entity.addPersistentProperty(property);
if (builder.isAssociation(field, descriptor)) {
@@ -184,13 +184,12 @@ public class BasicMappingContext implements MappingContext, InitializingBean {
this.builder = builder;
}
@SuppressWarnings({"unchecked"})
@Override
public boolean isPersistentEntity(Object value) {
if (null != value) {
Class clazz;
Class<?> clazz;
if (value instanceof Class) {
clazz = ((Class) value);
clazz = ((Class<?>) value);
} else {
clazz = value.getClass();
}

View File

@@ -25,7 +25,7 @@ import java.util.Map;
/**
* @author Jon Brisbin <jbrisbin@vmware.com>
*/
public class BasicPersistentEntity<T> implements PersistentEntity {
public class BasicPersistentEntity<T> implements PersistentEntity<T> {
protected final Class<T> type;
protected PreferredConstructor<T> preferredConstructor;
@@ -41,12 +41,12 @@ public class BasicPersistentEntity<T> implements PersistentEntity {
}
@Override
public PreferredConstructor getPreferredConstructor() {
public PreferredConstructor<T> getPreferredConstructor() {
return preferredConstructor;
}
@Override
public void setPreferredConstructor(PreferredConstructor constructor) {
public void setPreferredConstructor(PreferredConstructor<T> constructor) {
this.preferredConstructor = constructor;
}
@@ -61,7 +61,7 @@ public class BasicPersistentEntity<T> implements PersistentEntity {
}
@Override
public void setIdProperty(PersistentProperty property) {
public void setIdProperty(PersistentProperty<?> property) {
idProperty = property;
}
@@ -71,7 +71,7 @@ public class BasicPersistentEntity<T> implements PersistentEntity {
}
@Override
public void addPersistentProperty(PersistentProperty property) {
public void addPersistentProperty(PersistentProperty<?> property) {
persistentProperties.put(property.getName(), property);
}
@@ -85,7 +85,7 @@ public class BasicPersistentEntity<T> implements PersistentEntity {
associations.put(association.getInverse().getName(), association);
}
public PersistentProperty getPersistentProperty(String name) {
public PersistentProperty<?> getPersistentProperty(String name) {
return persistentProperties.get(name);
}

View File

@@ -22,7 +22,12 @@ package org.springframework.data.mapping.model;
*/
public class IllegalMappingException extends RuntimeException {
public IllegalMappingException(String s, Throwable throwable) {
/**
*
*/
private static final long serialVersionUID = 1L;
public IllegalMappingException(String s, Throwable throwable) {
super(s, throwable);
}

View File

@@ -30,9 +30,9 @@ public interface MappingConfigurationBuilder {
boolean isPersistentProperty(Field field, PropertyDescriptor descriptor) throws MappingConfigurationException;
PersistentProperty<?> createPersistentProperty(Field field, PropertyDescriptor descriptor) throws MappingConfigurationException;
<T> PersistentProperty<T> createPersistentProperty(Field field, PropertyDescriptor descriptor, Class<T> type) throws MappingConfigurationException;
<T> PreferredConstructor<?> getPreferredConstructor(Class<T> clazz) throws MappingConfigurationException;
<T> PreferredConstructor<T> getPreferredConstructor(Class<T> clazz) throws MappingConfigurationException;
boolean isAssociation(Field field, PropertyDescriptor descriptor) throws MappingConfigurationException;

View File

@@ -20,7 +20,12 @@ package org.springframework.data.mapping.model;
* @author Jon Brisbin <jbrisbin@vmware.com>
*/
public class MappingConfigurationException extends Throwable {
public MappingConfigurationException(String s) {
/**
*
*/
private static final long serialVersionUID = 1L;
public MappingConfigurationException(String s) {
super(s);
}

View File

@@ -20,7 +20,13 @@ package org.springframework.data.mapping.model;
* @author Jon Brisbin <jbrisbin@vmware.com>
*/
public class MappingException extends RuntimeException {
public MappingException(String s) {
/**
*
*/
private static final long serialVersionUID = 1L;
public MappingException(String s) {
super(s);
}

View File

@@ -17,14 +17,17 @@
package org.springframework.data.mapping.model;
/**
* Created by IntelliJ IDEA.
* User: jbrisbin
* Date: 2/25/11
* Time: 9:07 AM
* To change this template use File | Settings | File Templates.
* @author Jon Brisbin <jbrisbin@vmware.com>
*/
public class MappingInstantiationException extends RuntimeException {
public MappingInstantiationException(String s, Throwable throwable) {
/**
*
*/
private static final long serialVersionUID = 1L;
public MappingInstantiationException(String s, Throwable throwable) {
super(s, throwable);
}
}

View File

@@ -24,7 +24,7 @@ public interface PersistentEntity<T> extends InitializingBean {
PreferredConstructor<T> getPreferredConstructor();
void setPreferredConstructor(PreferredConstructor constructor);
void setPreferredConstructor(PreferredConstructor<T> constructor);
/**
* Returns the identity of the instance

View File

@@ -33,7 +33,6 @@ public class PreferredConstructor<T> {
public PreferredConstructor(Constructor<T> constructor) {
this.constructor = constructor;
this.parameters = parameters;
}
public Constructor<T> getConstructor() {