#671 - Remove list creation in ResourceSupport.getLink().

Since `ResourceSupport` has direct access to the list of links, no need to build up an intermedia `List` and then filter on it. Simply filter on the internal list of links. Also did some minor polishing.
This commit is contained in:
Johnny Lim
2017-11-15 14:24:02 +09:00
committed by Greg Turnquist
parent ad801e9003
commit d40bda2337

View File

@@ -32,6 +32,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
* Base class for DTOs to collect links.
*
* @author Oliver Gierke
* @author Johhny Lim
*/
public class ResourceSupport implements Identifiable<Link> {
@@ -123,7 +124,10 @@ public class ResourceSupport implements Identifiable<Link> {
* @return the link with the given rel or {@link Optional#empty()} if none found.
*/
public Optional<Link> getLink(String rel) {
return getLinks(rel).stream().findFirst();
return links.stream() //
.filter(link -> link.getRel().equals(rel)) //
.findFirst();
}
/**