diff --git a/src/main/java/org/springframework/hateoas/Link.java b/src/main/java/org/springframework/hateoas/Link.java index b48170a8..9d9dc4c3 100755 --- a/src/main/java/org/springframework/hateoas/Link.java +++ b/src/main/java/org/springframework/hateoas/Link.java @@ -68,6 +68,7 @@ public class Link implements Serializable { private @Wither String title; private @Wither String type; private @Wither String deprecation; + private @Wither String profile; private @JsonIgnore UriTemplate template; private @JsonIgnore List affordances; @@ -183,7 +184,7 @@ public class Link implements Serializable { public Link withAffordances(List affordances) { return new Link(this.rel, this.href, this.hreflang, this.media, this.title, this.type, this.deprecation, - this.template, affordances); + this.profile, this.template, affordances); } /** @@ -298,6 +299,10 @@ public class Link implements Serializable { linkString += ";deprecation=\"" + deprecation + "\""; } + if (profile != null) { + linkString += ";profile=\"" + profile + "\""; + } + return linkString; } @@ -349,6 +354,10 @@ public class Link implements Serializable { link = link.withDeprecation(attributes.get("deprecation")); } + if (attributes.containsKey("profile")) { + link = link.withProfile(attributes.get("profile")); + } + return link; } else { diff --git a/src/test/java/org/springframework/hateoas/LinkUnitTest.java b/src/test/java/org/springframework/hateoas/LinkUnitTest.java index 826ea508..6686b624 100755 --- a/src/test/java/org/springframework/hateoas/LinkUnitTest.java +++ b/src/test/java/org/springframework/hateoas/LinkUnitTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -110,6 +110,7 @@ public class LinkUnitTest { /** * @see #54 * @see #100 + * @see #678 */ @Test public void parsesRFC5988HeaderIntoLink() { @@ -122,13 +123,15 @@ public class LinkUnitTest { + "media=\"pdf\";" // + "title=\"pdf customer copy\";" // + "type=\"portable document\";" // - + "deprecation=\"http://example.com/customers/deprecated\"")) // + + "deprecation=\"http://example.com/customers/deprecated\";" // + + "profile=\"my-profile\"")) // .isEqualTo(new Link("/customer/1") // .withHreflang("en") // .withMedia("pdf") // .withTitle("pdf customer copy") // .withType("portable document") // - .withDeprecation("http://example.com/customers/deprecated")); + .withDeprecation("http://example.com/customers/deprecated") + .withProfile("my-profile")); } /**