diff --git a/src/main/java/org/springframework/hateoas/Link.java b/src/main/java/org/springframework/hateoas/Link.java index aa2468a2..cd55523b 100755 --- a/src/main/java/org/springframework/hateoas/Link.java +++ b/src/main/java/org/springframework/hateoas/Link.java @@ -251,6 +251,16 @@ public class Link implements Serializable { this.profile, this.name, this.template, affordances); } + /** + * Returns a new {@link Link} without any {@link Affordance}s. + * + * @return will never be {@literal null}. + * @since 3.0 + */ + public Link withoutAffordances() { + return withAffordances(Collections.emptyList()); + } + /** * Returns the variable names contained in the template. * @@ -289,13 +299,26 @@ public class Link implements Serializable { return template == null ? false : !template.getVariables().isEmpty(); } + /** + * Returns whether the links are logically the same, i.e. share all link characteristics but might have different + * affordances attached. + * + * @param other must not be {@literal null}. + * @since 3.0 + */ + public boolean isSameAs(Link other) { + + Assert.notNull(other, "Link must not be null!"); + + return withoutAffordances().equals(other.withoutAffordances()); + } + /** * Turns the current template into a {@link Link} by expanding it using the given parameters. * * @param arguments * @return */ - @SuppressWarnings("null") public Link expand(Object... arguments) { UriTemplate template = this.template;