GH-2336 - Enhance logical Link comparability.

This commit is contained in:
Oliver Drotbohm
2025-06-04 18:48:20 +02:00
parent 9d4096de93
commit 7527d2eea3

View File

@@ -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;