#805 - Added Links.getRequiredLink(…).
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user