#536 - Remove references to Assert single-arg methods.
Remove usage of calls to single-argument assertion methods by providing message. Original pull request: #537.
This commit is contained in:
committed by
Oliver Gierke
parent
276a7c1f70
commit
a16ea77c15
@@ -89,7 +89,7 @@ public class PagedResources<T> extends Resources<T> {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Resource<S>, S> PagedResources<T> wrap(Iterable<S> content, PageMetadata metadata) {
|
||||
|
||||
Assert.notNull(content);
|
||||
Assert.notNull(content, "Content must not be null!");
|
||||
ArrayList<T> resources = new ArrayList<T>();
|
||||
|
||||
for (S element : content) {
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Resources<T> extends ResourceSupport implements Iterable<T> {
|
||||
*/
|
||||
public Resources(Iterable<T> content, Iterable<Link> links) {
|
||||
|
||||
Assert.notNull(content);
|
||||
Assert.notNull(content, "Content must not be null!");
|
||||
|
||||
this.content = new ArrayList<T>();
|
||||
|
||||
@@ -83,7 +83,7 @@ public class Resources<T> extends ResourceSupport implements Iterable<T> {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Resource<S>, S> Resources<T> wrap(Iterable<S> content) {
|
||||
|
||||
Assert.notNull(content);
|
||||
Assert.notNull(content, "Content must not be null!");
|
||||
ArrayList<T> resources = new ArrayList<T>();
|
||||
|
||||
for (S element : content) {
|
||||
|
||||
@@ -35,7 +35,7 @@ public abstract class AbstractEntityLinks implements EntityLinks {
|
||||
*/
|
||||
@Override
|
||||
public Link linkToSingleResource(Identifiable<?> entity) {
|
||||
Assert.notNull(entity);
|
||||
Assert.notNull(entity, "Entity must not be null!");
|
||||
return linkToSingleResource(entity.getClass(), entity.getId());
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public abstract class AbstractEntityLinks implements EntityLinks {
|
||||
*/
|
||||
@Override
|
||||
public LinkBuilder linkForSingleResource(Identifiable<?> entity) {
|
||||
Assert.notNull(entity);
|
||||
Assert.notNull(entity, "Entity must not be null!");
|
||||
return linkForSingleResource(entity.getClass(), entity.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class AnnotationAttribute {
|
||||
*/
|
||||
public AnnotationAttribute(Class<? extends Annotation> annotationType, String attributeName) {
|
||||
|
||||
Assert.notNull(annotationType);
|
||||
Assert.notNull(annotationType, "AnnotationType must not be null!");
|
||||
|
||||
this.annotationType = annotationType;
|
||||
this.attributeName = attributeName;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class AnnotationMappingDiscoverer implements MappingDiscoverer {
|
||||
*/
|
||||
public AnnotationMappingDiscoverer(Class<? extends Annotation> annotation, String mappingAttributeName) {
|
||||
|
||||
Assert.notNull(annotation);
|
||||
Assert.notNull(annotation, "Annotation must not be null!");
|
||||
|
||||
this.annotationType = annotation;
|
||||
this.mappingAttributeName = mappingAttributeName;
|
||||
|
||||
@@ -65,8 +65,8 @@ public class ControllerEntityLinks extends AbstractEntityLinks {
|
||||
public ControllerEntityLinks(Iterable<? extends Class<?>> controllerTypes,
|
||||
LinkBuilderFactory<? extends LinkBuilder> linkBuilderFactory) {
|
||||
|
||||
Assert.notNull(controllerTypes);
|
||||
Assert.notNull(linkBuilderFactory);
|
||||
Assert.notNull(controllerTypes, "ControllerTypes must not be null!");
|
||||
Assert.notNull(linkBuilderFactory, "LinkBuilderFactory must not be null!");
|
||||
|
||||
this.linkBuilderFactory = linkBuilderFactory;
|
||||
this.entityToController = new HashMap<Class<?>, Class<?>>();
|
||||
@@ -105,7 +105,7 @@ public class ControllerEntityLinks extends AbstractEntityLinks {
|
||||
@Override
|
||||
public LinkBuilder linkFor(Class<?> entity, Object... parameters) {
|
||||
|
||||
Assert.notNull(entity);
|
||||
Assert.notNull(entity, "Entity must not be null!");
|
||||
|
||||
Class<?> controllerType = entityToController.get(entity);
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ControllerEntityLinksFactoryBean extends AbstractFactoryBean<Contro
|
||||
* @param annotation must not be {@literal null}.
|
||||
*/
|
||||
public void setAnnotation(Class<? extends Annotation> annotation) {
|
||||
Assert.notNull(annotation);
|
||||
Assert.notNull(annotation, "Annotation must not be null!");
|
||||
this.annotation = annotation;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class MethodParameters {
|
||||
*/
|
||||
public MethodParameters(Method method, AnnotationAttribute namingAnnotation) {
|
||||
|
||||
Assert.notNull(method);
|
||||
Assert.notNull(method, "Method must not be null!");
|
||||
this.parameters = new ArrayList<MethodParameter>();
|
||||
|
||||
for (int i = 0; i < method.getParameterTypes().length; i++) {
|
||||
@@ -131,7 +131,7 @@ public class MethodParameters {
|
||||
return cached;
|
||||
}
|
||||
|
||||
Assert.notNull(annotation);
|
||||
Assert.notNull(annotation, "Annotation must not be null!");
|
||||
List<MethodParameter> result = new ArrayList<MethodParameter>();
|
||||
|
||||
for (MethodParameter parameter : getParameters()) {
|
||||
|
||||
@@ -32,10 +32,10 @@ public class ControllerRelProvider implements RelProvider {
|
||||
|
||||
public ControllerRelProvider(Class<?> controller, PluginRegistry<RelProvider, Class<?>> providers) {
|
||||
|
||||
Assert.notNull(controller);
|
||||
Assert.notNull(controller, "Controller must not be null!");
|
||||
|
||||
ExposesResourceFor annotation = AnnotationUtils.findAnnotation(controller, ExposesResourceFor.class);
|
||||
Assert.notNull(annotation);
|
||||
Assert.notNull(annotation, "Controller must be annotated with ExposesResourceFor!");
|
||||
|
||||
this.controllerType = controller;
|
||||
this.entityType = annotation.value();
|
||||
|
||||
@@ -66,8 +66,8 @@ public abstract class IdentifiableResourceAssemblerSupport<T extends Identifiabl
|
||||
@Override
|
||||
protected D createResourceWithId(Object id, T entity, Object... parameters) {
|
||||
|
||||
Assert.notNull(entity);
|
||||
Assert.notNull(id);
|
||||
Assert.notNull(entity, "Entity must not be null!");
|
||||
Assert.notNull(id, "Id must not be null!");
|
||||
|
||||
D instance = instantiateResource(entity);
|
||||
instance.add(linkTo(controllerClass, unwrapIdentifyables(parameters)).slash(id).withSelfRel());
|
||||
|
||||
@@ -44,8 +44,8 @@ public abstract class ResourceAssemblerSupport<T, D extends ResourceSupport> imp
|
||||
*/
|
||||
public ResourceAssemblerSupport(Class<?> controllerClass, Class<D> resourceType) {
|
||||
|
||||
Assert.notNull(controllerClass);
|
||||
Assert.notNull(resourceType);
|
||||
Assert.notNull(controllerClass, "ControllerClass must not be null!");
|
||||
Assert.notNull(resourceType, "ResourceType must not be null!");
|
||||
|
||||
this.controllerClass = controllerClass;
|
||||
this.resourceType = resourceType;
|
||||
@@ -60,7 +60,7 @@ public abstract class ResourceAssemblerSupport<T, D extends ResourceSupport> imp
|
||||
*/
|
||||
public List<D> toResources(Iterable<? extends T> entities) {
|
||||
|
||||
Assert.notNull(entities);
|
||||
Assert.notNull(entities, "Entities must not be null!");
|
||||
List<D> result = new ArrayList<D>();
|
||||
|
||||
for (T entity : entities) {
|
||||
@@ -83,8 +83,8 @@ public abstract class ResourceAssemblerSupport<T, D extends ResourceSupport> imp
|
||||
|
||||
protected D createResourceWithId(Object id, T entity, Object... parameters) {
|
||||
|
||||
Assert.notNull(entity);
|
||||
Assert.notNull(id);
|
||||
Assert.notNull(entity, "Entity must not be null!");
|
||||
Assert.notNull(id, "Id must not be null!");
|
||||
|
||||
D instance = instantiateResource(entity);
|
||||
instance.add(linkTo(controllerClass, parameters).slash(id).withSelfRel());
|
||||
|
||||
@@ -199,7 +199,7 @@ public class ResourceProcessorInvoker {
|
||||
*/
|
||||
public DefaultProcessorWrapper(ResourceProcessor<?> processor) {
|
||||
|
||||
Assert.notNull(processor);
|
||||
Assert.notNull(processor, "Processor must not be null!");
|
||||
|
||||
this.processor = processor;
|
||||
this.targetType = ResolvableType.forClass(ResourceProcessor.class, processor.getClass()).getGeneric(0);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class TypeReferences {
|
||||
Type type = parameterizedTypeReferenceSubclass.getGenericSuperclass();
|
||||
Assert.isInstanceOf(ParameterizedType.class, type);
|
||||
ParameterizedType parameterizedType = (ParameterizedType) type;
|
||||
Assert.isTrue(parameterizedType.getActualTypeArguments().length == 1);
|
||||
Assert.isTrue(parameterizedType.getActualTypeArguments().length == 1, String.format("Type must have exactly one gerneric type argument but has %s.", parameterizedType.getActualTypeArguments().length));
|
||||
|
||||
Class<?> resourceType = GenericTypeResolver.resolveType(parameterizedType.getActualTypeArguments()[0],
|
||||
new HashMap<TypeVariable, Type>());
|
||||
|
||||
Reference in New Issue
Block a user