#137 - Initial support for link templates.
Added LinkTemplate domain type that can deal with URI templates as defined in http://tools.ietf.org/html/rfc6570. We currently support /, ?, & and # variables up to level 3 of the spec (multiple parameter definitions). The templates can be expanded to a Link instance. Added the necessary HAL mixins to render the instances as specified.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2012-2014 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.
|
||||
@@ -27,6 +27,7 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.LinkTemplate;
|
||||
import org.springframework.hateoas.RelProvider;
|
||||
import org.springframework.hateoas.Resource;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
@@ -80,6 +81,7 @@ public class Jackson2HalModule extends SimpleModule {
|
||||
super("json-hal-module", new Version(1, 0, 0, null, "org.springframework.hateoas", "spring-hateoas"));
|
||||
|
||||
setMixInAnnotation(Link.class, LinkMixin.class);
|
||||
setMixInAnnotation(LinkTemplate.class, LinkTemplateMixin.class);
|
||||
setMixInAnnotation(ResourceSupport.class, ResourceSupportMixin.class);
|
||||
setMixInAnnotation(Resources.class, ResourcesMixin.class);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.hateoas.hal;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.hateoas.LinkTemplate;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* Mixin for {@link LinkTemplate}s.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
abstract class LinkTemplateMixin extends LinkMixin {
|
||||
|
||||
private static final long serialVersionUID = -7227899604445243148L;
|
||||
|
||||
@JsonIgnore
|
||||
public abstract List<String> getVariableNames();
|
||||
}
|
||||
Reference in New Issue
Block a user