#805 - Added Links.getRequiredLink(…).

This commit is contained in:
Oliver Drotbohm
2019-02-11 10:41:25 +01:00
parent a9bae74dcf
commit 1dea5f61b9
2 changed files with 32 additions and 0 deletions

View File

@@ -71,6 +71,19 @@ public class Links implements Iterable<Link> {
.filter(link -> link.getRel().equals(rel)).findFirst();
}
/**
* Returns the {@link Link} with the given relation.
*
* @param rel the relation type to lookup a link for.
* @return
* @throws IllegalArgumentException if no link with the given relation was present.
* @since 1.0
*/
public Link getRequiredLink(String rel) {
return getLink(rel) //
.orElseThrow(() -> new IllegalArgumentException(String.format("Couldn't find link with rel '%s'!", rel)));
}
/**
* Returns all {@link Links} with the given relation type.
*