#678 - Add 'profile' to Link.
Fully support HAL spec by adding "profile" as another optional attribute to `Link`. See: https://tools.ietf.org/html/draft-kelly-json-hal-08, https://tools.ietf.org/html/rfc5988
This commit is contained in:
@@ -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<Affordance> affordances;
|
||||
|
||||
@@ -183,7 +184,7 @@ public class Link implements Serializable {
|
||||
public Link withAffordances(List<Affordance> 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 {
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user