Skip to content

Commit ae30cff

Browse files
committed
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 2f08735 commit ae30cff

12 files changed

+1290
-952
lines changed

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

Lines changed: 521 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
@@ -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

@@ -112,7 +113,7 @@ public static Links valueOf(String source) {
112113
if (!StringUtils.hasText(source)) {
113114
return NO_LINKS;
114115
}
115-
116+
116117
Matcher matcher = LINK_HEADER_PATTERN.matcher(source);
117118
List<Link> links = new ArrayList<Link>();
118119

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+
}

0 commit comments

Comments
 (0)