#791 - Add 'name' property to Link. (#801)

This commit is contained in:
Greg Turnquist
2019-02-07 08:13:49 -06:00
committed by GitHub
parent 9590d1f9ef
commit 9518a2db9a
3 changed files with 34 additions and 6 deletions

View File

@@ -50,7 +50,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
@JsonIgnoreProperties(value = "templated", ignoreUnknown = true)
@AllArgsConstructor(access = AccessLevel.PACKAGE)
@Getter
@EqualsAndHashCode(of = { "rel", "href", "hreflang", "media", "title", "deprecation", "affordances" })
@EqualsAndHashCode(of = { "rel", "href", "hreflang", "media", "title", "type", "deprecation", "profile", "name", "affordances" })
public class Link implements Serializable {
private static final long serialVersionUID = -9037755944661782121L;
@@ -100,6 +100,7 @@ public class Link implements Serializable {
private @Wither String type;
private @Wither String deprecation;
private @Wither String profile;
private @Wither String name;
private @JsonIgnore UriTemplate template;
private @JsonIgnore List<Affordance> affordances;
@@ -257,7 +258,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.profile, this.template, affordances);
this.profile, this.name, this.template, affordances);
}
/**
@@ -324,11 +325,11 @@ public class Link implements Serializable {
private UriTemplate getUriTemplate() {
if (template == null) {
if (this.template == null) {
this.template = new UriTemplate(href);
}
return template;
return this.template;
}
/*
@@ -364,6 +365,10 @@ public class Link implements Serializable {
linkString += ";profile=\"" + profile + "\"";
}
if (name != null) {
linkString += ";name=\"" + name + "\"";
}
return linkString;
}
@@ -418,6 +423,10 @@ public class Link implements Serializable {
link = link.withProfile(attributes.get("profile"));
}
if (attributes.containsKey("name")) {
link = link.withName(attributes.get("name"));
}
return link;
} else {