Revisit Assert to avoid single-arg assert methods (with refined messages)

Issue: SPR-15196
This commit is contained in:
Juergen Hoeller
2017-01-30 22:15:53 +01:00
parent 768802fa96
commit 1b2dc3638f
118 changed files with 708 additions and 828 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -79,7 +79,6 @@ import org.springframework.oxm.UncategorizedMappingException;
import org.springframework.oxm.UnmarshallingFailureException;
import org.springframework.oxm.XmlMappingException;
import org.springframework.oxm.support.AbstractMarshaller;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
@@ -114,7 +113,7 @@ import org.springframework.util.xml.StaxUtils;
* @author Juergen Hoeller
* @since 3.0
*/
public class XStreamMarshaller extends AbstractMarshaller implements InitializingBean, BeanClassLoaderAware {
public class XStreamMarshaller extends AbstractMarshaller implements BeanClassLoaderAware, InitializingBean {
/**
* The default encoding used for stream access: UTF-8.
@@ -130,7 +129,7 @@ public class XStreamMarshaller extends AbstractMarshaller implements Initializin
private Mapper mapper;
private Class<?>[] mapperWrappers;
private Class<? extends MapperWrapper>[] mapperWrappers;
private ConverterLookup converterLookup = new DefaultConverterLookup();
@@ -210,7 +209,8 @@ public class XStreamMarshaller extends AbstractMarshaller implements Initializin
* of type {@link Mapper} or {@link MapperWrapper}.
* @since 4.0
*/
public void setMapperWrappers(Class<?>... mapperWrappers) {
@SuppressWarnings("unchecked")
public void setMapperWrappers(Class<? extends MapperWrapper>... mapperWrappers) {
this.mapperWrappers = mapperWrappers;
}
@@ -413,9 +413,8 @@ public class XStreamMarshaller extends AbstractMarshaller implements Initializin
protected MapperWrapper wrapMapper(MapperWrapper next) {
MapperWrapper mapperToWrap = next;
if (mapperWrappers != null) {
for (Class<?> mapperWrapper : mapperWrappers) {
Assert.isAssignable(MapperWrapper.class, mapperWrapper);
Constructor<?> ctor;
for (Class<? extends MapperWrapper> mapperWrapper : mapperWrappers) {
Constructor<? extends MapperWrapper> ctor;
try {
ctor = mapperWrapper.getConstructor(Mapper.class);
}
@@ -428,9 +427,9 @@ public class XStreamMarshaller extends AbstractMarshaller implements Initializin
}
}
try {
mapperToWrap = (MapperWrapper) ctor.newInstance(mapperToWrap);
mapperToWrap = ctor.newInstance(mapperToWrap);
}
catch (Exception ex) {
catch (Throwable ex) {
throw new IllegalStateException("Failed to construct MapperWrapper: " + mapperWrapper);
}
}