#667 - Fix Link to ignore setting "templated" properties.

Deserializing a Link with a templated URI will cause Jackson to break due to there being no "templated" property. This adds a private, no-op `setTemplated` method to allow deserialization to occur yet not alter the Link..
This commit is contained in:
Greg Turnquist
2017-11-14 17:39:20 -06:00
parent 367f560745
commit d5649c0de1
2 changed files with 35 additions and 2 deletions

View File

@@ -207,7 +207,7 @@ public class Link implements Serializable {
}
/**
* Returns whether the link is templated.
* Returns whether or not the link is templated.
*
* @return
*/
@@ -215,6 +215,18 @@ public class Link implements Serializable {
return !getUriTemplate().getVariables().isEmpty();
}
/**
* This no-op setter is required to deserialize a link that contains a templated URL. It allows Jackson to
* "set" the property, but since {@code templated} is a virtual property, the injected value {@code true} or
* {@code false) is ignored.
*
* The method is kept private so no one attempts to actually use it.
*
* @param __ - don't care what value is passed in. The true value {@link #isTemplated()} is based upon the {@link UriTemplate}.
*/
private void setTemplated(boolean __) {
}
/**
* Turns the current template into a {@link Link} by expanding it using the given parameters.
*