Package org.springframework.hateoas
Class Links
java.lang.Object
org.springframework.hateoas.Links
Value object to represent a list of
Links.- Author:
- Oliver Gierke, Greg Turnquist
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionfinal LinksAdds the given links if the given condition is true.final LinksAdds the given links if the given condition is true.final LinksAdds the given links if the given condition is true.booleanbooleanbooleancontainsSameLinksAs(Iterable<Link> links) booleanReturns aLinkwith the given relation if contained in the currentLinksinstance,Optional.empty()otherwise.getLink(LinkRelation rel) Returns theLinkwith the given rel.getRequiredLink(String rel) Returns theLinkwith the given relation.getRequiredLink(LinkRelation relation) Returns theLinkwith the given relation.inthashCode()booleanbooleanhasLink(LinkRelation relation) booleanbooleanhasSize(long size) Returns whether the currentLinkshas the given size.booleanisEmpty()Returns whether theLinkscontainer is empty.iterator()merge(Links.MergeMode mode, Iterable<Link> links) Merges the currentLinkswith the given ones applying the givenLinks.MergeMode.merge(Links.MergeMode mode, Stream<Link> links) Merges the currentLinkswith the given ones applying the givenLinks.MergeMode.merge(Links.MergeMode mode, Link... links) Merges the currentLinkswith the given ones applying the givenLinks.MergeMode.static Linksstatic Linksstatic LinksCreates aLinksinstance from the given RFC-8288-compatible link format.stream()toList()toString()without(LinkRelation relation) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
NONE
-
-
Method Details
-
of
- Parameters:
links-
-
of
- Parameters:
links-
-
parse
Creates aLinksinstance from the given RFC-8288-compatible link format. -
and
- Parameters:
links- must not be null.- Returns:
- See Also:
-
andIf
Adds the given links if the given condition is true. The givenLinks will only be resolved if the given condition is true. Essentially syntactic sugar to write:
if (a > 3) { links = links.and(…); }aslinks = link.andIf(a > 3, …);- Parameters:
condition-links- must not be null.- Returns:
-
andIf
Adds the given links if the given condition is true. The givenSuppliers will only be resolved if the given condition is true. Essentially syntactic sugar to write:
if (a > 3) { links = links.and(…); }aslinks = link.andIf(a > 3, …);- Parameters:
condition-links- must not be null.- Returns:
-
andIf
Adds the given links if the given condition is true. The givenStreamwill only be resolved if the given condition is true. Essentially syntactic sugar to write:
if (a > 3) { links = links.and(…); }aslinks = link.andIf(a > 3, …);- Parameters:
condition-links- must not be null.- Returns:
-
and
Creates a newLinksinstance with all givenLinks added. For conditional adding seemerge(Iterable).- Parameters:
links- must not be null.- Returns:
- See Also:
-
and
Creates a newLinksinstance with all givenLinks added. For conditional adding seemerge(Iterable).- Parameters:
links- must not be null.- Returns:
- See Also:
-
merge
Merges the currentLinkswith the given ones, skippingLinks already contained in the current instance. For unconditional combination seeand(Link...).- Parameters:
links- theLinks to be merged, must not be null.- Returns:
- See Also:
-
merge
Merges the currentLinkswith the given ones, skippingLinks already contained in the current instance. For unconditional combination seeand(Stream).- Parameters:
links- theLinks to be merged, must not be null.- Returns:
- See Also:
-
merge
Merges the currentLinkswith the given ones, skippingLinks already contained in the current instance. For unconditional combination seeand(Iterable).- Parameters:
links- theLinks to be merged, must not be null.- Returns:
- See Also:
-
merge
Merges the currentLinkswith the given ones applying the givenLinks.MergeMode.- Parameters:
mode- must not be null.links- must not be null.- Returns:
-
merge
Merges the currentLinkswith the given ones applying the givenLinks.MergeMode.- Parameters:
mode- must not be null.links- must not be null.- Returns:
-
merge
Merges the currentLinkswith the given ones applying the givenLinks.MergeMode.- Parameters:
mode- must not be null.links- must not be null.- Returns:
-
without
- Parameters:
relation- must not be null.- Returns:
-
getLink
Returns aLinkwith the given relation if contained in the currentLinksinstance,Optional.empty()otherwise.- Parameters:
relation- must not be null or empty.- Returns:
-
getLink
Returns theLinkwith the given rel.- Parameters:
rel- the relation type to lookup a link for.- Returns:
- the link with the given rel or Optional#empty() if none found.
-
getRequiredLink
Returns theLinkwith the given relation.- Parameters:
rel- the relation type to lookup a link for.- Returns:
- Throws:
IllegalArgumentException- if no link with the given relation was present.- Since:
- 1.0
-
getRequiredLink
Returns theLinkwith the given relation.- Parameters:
relation- the relation type to lookup a link for.- Returns:
- Throws:
IllegalArgumentException- if no link with the given relation was present.
-
hasLink
- Parameters:
relation- must not be null or empty.- Returns:
-
hasLink
- Parameters:
relation- must not be null.- Returns:
-
isEmpty
public boolean isEmpty()Returns whether theLinkscontainer is empty.- Returns:
-
hasSize
public boolean hasSize(long size) Returns whether the currentLinkshas the given size.- Parameters:
size-- Returns:
-
hasSingleLink
public boolean hasSingleLink()- Returns:
-
stream
- Returns:
-
toList
- Returns:
-
contains
- Parameters:
links- must not be null.- Returns:
-
contains
- Parameters:
links- must not be null.- Returns:
-
containsSameLinksAs
- Parameters:
links- must not be null.- Returns:
-
collector
- Returns:
- will never be null.
-
toString
-
iterator
-
equals
-
hashCode
public int hashCode()
-