Skip to content

Commit 2d94871

Browse files
committed
#560 - Add extra attributes to Link and use for HAL mediatype
Adds many additional attributes defined in RFC5988 and verifies they work properly in the neutral representation of Link while also being rendered properly in the HAL module. Additionally, some of the files had inconsistent EOL characters. This patches that as well. To see the differences WITHOUT this bit, add ?w=1 to the github page showing the delta, and whitespace differences will be filtered out. Resolves #100,#417,#235,#240,#238,#223
1 parent 0e8b0e1 commit 2d94871

12 files changed

+1162
-785
lines changed

src/main/java/org/springframework/hateoas/Link.java

Lines changed: 523 additions & 295 deletions
Large diffs are not rendered by default.

src/main/java/org/springframework/hateoas/Links.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2016 the original author or authors.
2+
* Copyright 2013-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,10 +29,11 @@
2929
* Value object to represent a list of {@link Link}s.
3030
*
3131
* @author Oliver Gierke
32+
* @author Greg Turnquist
3233
*/
3334
public class Links implements Iterable<Link> {
3435

35-
private static final Pattern LINK_HEADER_PATTERN = Pattern.compile("(<[^>]*>;rel=\"[^\"]*\")");
36+
private static final Pattern LINK_HEADER_PATTERN = Pattern.compile("(<[^>]*>(;\\w+=\"[^\"]*\")+)");
3637

3738
static final Links NO_LINKS = new Links(Collections.<Link> emptyList());
3839

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
/*
2-
* Copyright 2012 the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
package org.springframework.hateoas;
17-
18-
/**
19-
* Interface for components that convert a domain type into an {@link ResourceSupport}.
20-
*
21-
* @author Oliver Gierke
22-
*/
23-
public interface ResourceAssembler<T, D extends ResourceSupport> {
24-
25-
/**
26-
* Converts the given entity into an {@link ResourceSupport}.
27-
*
28-
* @param entity
29-
* @return
30-
*/
31-
D toResource(T entity);
32-
}
1+
/*
2+
* Copyright 2012 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.hateoas;
17+
18+
/**
19+
* Interface for components that convert a domain type into an {@link ResourceSupport}.
20+
*
21+
* @author Oliver Gierke
22+
*/
23+
public interface ResourceAssembler<T, D extends ResourceSupport> {
24+
25+
/**
26+
* Converts the given entity into an {@link ResourceSupport}.
27+
*
28+
* @param entity
29+
* @return
30+
*/
31+
D toResource(T entity);
32+
}

src/main/java/org/springframework/hateoas/ResourceSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public List<Link> getLinks(String rel) {
151151
return relatedLinks;
152152
}
153153

154-
/*
154+
/*
155155
* (non-Javadoc)
156156
* @see java.lang.Object#toString()
157157
*/

src/main/java/org/springframework/hateoas/hal/LinkMixin.java

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2014 the original author or authors.
2+
* Copyright 2012-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,13 +28,46 @@
2828
*
2929
* @author Alexander Baetz
3030
* @author Oliver Gierke
31+
* @author Greg Turnquist
3132
*/
32-
@JsonIgnoreProperties(value = "rel")
33+
@JsonIgnoreProperties({"rel", "media"})
3334
abstract class LinkMixin extends Link {
3435

3536
private static final long serialVersionUID = 4720588561299667409L;
3637

37-
/*
38+
/*
39+
* (non-Javadoc)
40+
* @see org.springframework.hateoas.Link#getHreflang()
41+
*/
42+
@Override
43+
@JsonInclude(Include.NON_NULL)
44+
public abstract String getHreflang();
45+
46+
/*
47+
* (non-Javadoc)
48+
* @see org.springframework.hateoas.Link#getTitle()
49+
*/
50+
@Override
51+
@JsonInclude(Include.NON_NULL)
52+
public abstract String getTitle();
53+
54+
/*
55+
* (non-Javadoc)
56+
* @see org.springframework.hateoas.Link#getType()
57+
*/
58+
@Override
59+
@JsonInclude(Include.NON_NULL)
60+
public abstract String getType();
61+
62+
/*
63+
* (non-Javadoc)
64+
* @see org.springframework.hateoas.Link#getDeprecation()
65+
*/
66+
@Override
67+
@JsonInclude(Include.NON_NULL)
68+
public abstract String getDeprecation();
69+
70+
/*
3871
* (non-Javadoc)
3972
* @see org.springframework.hateoas.Link#isTemplate()
4073
*/

0 commit comments

Comments
 (0)