Polished Javadoc of ControllerLinkBuilder.

This commit is contained in:
Oliver Gierke
2012-08-28 18:27:40 +02:00
parent 91a6e99e3f
commit b33231ffaa

View File

@@ -50,15 +50,25 @@ public class ControllerLinkBuilder {
/**
* Creates a new {@link ControllerLinkBuilder} with a base of the mapping annotated to the given controller class.
*
* @param controller
* @param controller must not be {@literal null}.
* @return
*/
public static ControllerLinkBuilder linkTo(Class<?> controller) {
return linkTo(controller, new Object[0]);
}
/**
* Creates a new {@link ControllerLinkBuilder} with a base of the mapping annotated to the given controller class. The
* additional parameters are used to fill up potentially available path variables in the class scop request mapping.
*
* @param controller must not be {@literal null}.
* @param parameters
* @return
*/
public static ControllerLinkBuilder linkTo(Class<?> controller, Object... parameters) {
Assert.notNull(controller);
RequestMapping annotation = AnnotationUtils.findAnnotation(controller, RequestMapping.class);
String[] mapping = annotation == null ? new String[0] : (String[]) AnnotationUtils.getValue(annotation);
@@ -117,10 +127,22 @@ public class ControllerLinkBuilder {
return uriComponents.encode().toUri();
}
/**
* Creates the {@link Link} built by the current builder instance with the given rel.
*
* @param rel must not be {@literal null} or empty.
* @return
*/
public Link withRel(String rel) {
return new Link(this.toString(), rel);
}
/**
* Creates the {@link Link} built by the current builder instance with the default self rel.
*
* @see Link#REL_SELF
* @return
*/
public Link withSelfRel() {
return new Link(this.toString());
}