#398 - Polishing.
Some JavaDoc, formatting, copyright year expansion and author tags. Test method ordering. Original pull request: #422.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
@@ -33,6 +33,7 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
* @author Ricardo Gladwell
|
||||
* @author Oliver Gierke
|
||||
* @author Kamill Sokol
|
||||
* @author Kevin Conaway
|
||||
*/
|
||||
public abstract class LinkBuilderSupport<T extends LinkBuilder> implements LinkBuilder {
|
||||
|
||||
@@ -45,12 +46,18 @@ public abstract class LinkBuilderSupport<T extends LinkBuilder> implements LinkB
|
||||
*/
|
||||
public LinkBuilderSupport(UriComponentsBuilder builder) {
|
||||
|
||||
Assert.notNull(builder);
|
||||
Assert.notNull(builder, "UriComponentsBuilder must not be null!");
|
||||
this.uriComponents = builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link LinkBuilderSupport} using the given {@link UriComponents}.
|
||||
*
|
||||
* @param uriComponents must not be {@literal null}.
|
||||
*/
|
||||
public LinkBuilderSupport(UriComponents uriComponents) {
|
||||
Assert.notNull(uriComponents);
|
||||
|
||||
Assert.notNull(uriComponents, "UriComponents must not be null!");
|
||||
this.uriComponents = uriComponents;
|
||||
}
|
||||
|
||||
@@ -79,8 +86,7 @@ public abstract class LinkBuilderSupport<T extends LinkBuilder> implements LinkB
|
||||
}
|
||||
|
||||
String uriString = uriComponents.toUriString();
|
||||
UriComponentsBuilder builder = uriString.isEmpty() ? fromUri(uriComponents.toUri())
|
||||
: fromUriString(uriString);
|
||||
UriComponentsBuilder builder = uriString.isEmpty() ? fromUri(uriComponents.toUri()) : fromUriString(uriString);
|
||||
|
||||
UriComponents components = UriComponentsBuilder.fromUriString(path).build();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
@@ -43,6 +43,7 @@ import org.springframework.web.util.UriTemplate;
|
||||
* @author Oliver Gierke
|
||||
* @author Kamill Sokol
|
||||
* @author Greg Turnquist
|
||||
* @author Kevin Conaway
|
||||
*/
|
||||
public class ControllerLinkBuilder extends LinkBuilderSupport<ControllerLinkBuilder> {
|
||||
|
||||
@@ -60,15 +61,15 @@ public class ControllerLinkBuilder extends LinkBuilderSupport<ControllerLinkBuil
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link ControllerLinkBuilder} using the given {@link UriComponents}.
|
||||
*
|
||||
* @param uriComponents must not be {@literal null}.
|
||||
*/
|
||||
ControllerLinkBuilder(UriComponents uriComponents) {
|
||||
super(uriComponents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link ControllerLinkBuilder} using the given {@link UriComponents}.
|
||||
*
|
||||
* @param uriComponents must not be {@literal null}.
|
||||
*/
|
||||
ControllerLinkBuilder(UriComponents uriComponents) {
|
||||
super(uriComponents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link ControllerLinkBuilder} with a base of the mapping annotated to the given controller class.
|
||||
*
|
||||
* @param controller the class to discover the annotation on, must not be {@literal null}.
|
||||
@@ -104,7 +105,7 @@ public class ControllerLinkBuilder extends LinkBuilderSupport<ControllerLinkBuil
|
||||
* @see org.springframework.hateoas.MethodLinkBuilderFactory#linkTo(Method, Object...)
|
||||
*/
|
||||
public static ControllerLinkBuilder linkTo(Method method, Object... parameters) {
|
||||
return linkTo(method.getDeclaringClass(), method, parameters);
|
||||
return linkTo(method.getDeclaringClass(), method, parameters);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -126,10 +127,10 @@ public class ControllerLinkBuilder extends LinkBuilderSupport<ControllerLinkBuil
|
||||
* you can create via {@link #methodOn(Class, Object...)} or {@link DummyInvocationUtils#methodOn(Class, Object...)}.
|
||||
*
|
||||
* <pre>
|
||||
* @RequestMapping("/customers")
|
||||
* @RequestMapping("/customers")
|
||||
* class CustomerController {
|
||||
*
|
||||
* @RequestMapping("/{id}/addresses")
|
||||
* @RequestMapping("/{id}/addresses")
|
||||
* HttpEntity<Addresses> showAddresses(@PathVariable Long id) { … }
|
||||
* }
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
@@ -55,6 +55,7 @@ import org.springframework.web.util.UriTemplate;
|
||||
* @author Kamill Sokol
|
||||
* @author Ross Turner
|
||||
* @author Oemer Yildiz
|
||||
* @author Kevin Conaway
|
||||
*/
|
||||
public class ControllerLinkBuilderFactory implements MethodLinkBuilderFactory<ControllerLinkBuilder> {
|
||||
|
||||
@@ -156,7 +157,8 @@ public class ControllerLinkBuilderFactory implements MethodLinkBuilderFactory<Co
|
||||
* @param invocation will never be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
protected UriComponentsBuilder applyUriComponentsContributer(UriComponentsBuilder builder, MethodInvocation invocation) {
|
||||
protected UriComponentsBuilder applyUriComponentsContributer(UriComponentsBuilder builder,
|
||||
MethodInvocation invocation) {
|
||||
|
||||
MethodParameters parameters = new MethodParameters(invocation.getMethod());
|
||||
Iterator<Object> parameterValues = Arrays.asList(invocation.getArguments()).iterator();
|
||||
@@ -235,8 +237,8 @@ public class ControllerLinkBuilderFactory implements MethodLinkBuilderFactory<Co
|
||||
protected Object verifyParameterValue(MethodParameter parameter, Object value) {
|
||||
|
||||
RequestParam annotation = parameter.getParameterAnnotation(RequestParam.class);
|
||||
return annotation.required() && annotation.defaultValue().equals(ValueConstants.DEFAULT_NONE) ? super
|
||||
.verifyParameterValue(parameter, value) : value;
|
||||
return annotation.required() && annotation.defaultValue().equals(ValueConstants.DEFAULT_NONE)
|
||||
? super.verifyParameterValue(parameter, value) : value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user