Package org.springframework.hateoas
Class Links
java.lang.Object
org.springframework.hateoas.Links
Value object to represent a list of
Link
s.- Author:
- Oliver Gierke, Greg Turnquist, Viliam Durina
-
Nested Class Summary
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal Links
Adds the given links if the given condition is true.final Links
Adds the given links if the given condition is true.final Links
Adds the given links if the given condition is true.boolean
boolean
boolean
containsSameLinksAs
(Iterable<Link> links) boolean
Returns aLink
with the given relation if contained in the currentLinks
instance,Optional.empty()
otherwise.getLink
(LinkRelation rel) Returns theLink
with the given rel.getRequiredLink
(String rel) Returns theLink
with the given relation.getRequiredLink
(LinkRelation relation) Returns theLink
with the given relation.int
hashCode()
boolean
boolean
hasLink
(LinkRelation relation) boolean
boolean
hasSize
(long size) Returns whether the currentLinks
has the given size.boolean
isEmpty()
Returns whether theLinks
container is empty.iterator()
merge
(Links.MergeMode mode, Iterable<Link> links) Merges the currentLinks
with the given ones applying the givenLinks.MergeMode
.merge
(Links.MergeMode mode, Stream<Link> links) Merges the currentLinks
with the given ones applying the givenLinks.MergeMode
.merge
(Links.MergeMode mode, Link... links) Merges the currentLinks
with the given ones applying the givenLinks.MergeMode
.static Links
static Links
static Links
Creates aLinks
instance 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, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
NONE
-
-
Method Details
-
of
- Parameters:
links
-
-
of
- Parameters:
links
-
-
parse
Creates aLinks
instance 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 givenLink
s 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 givenSupplier
s 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 givenStream
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:
-
and
Creates a newLinks
instance with all givenLink
s added. For conditional adding seemerge(Iterable)
.- Parameters:
links
- must not be null.- Returns:
- See Also:
-
and
Creates a newLinks
instance with all givenLink
s added. For conditional adding seemerge(Iterable)
.- Parameters:
links
- must not be null.- Returns:
- See Also:
-
merge
Merges the currentLinks
with the given ones, skippingLink
s already contained in the current instance. For unconditional combination seeand(Link...)
.- Parameters:
links
- theLink
s to be merged, must not be null.- Returns:
- See Also:
-
merge
Merges the currentLinks
with the given ones, skippingLink
s already contained in the current instance. For unconditional combination seeand(Stream)
.- Parameters:
links
- theLink
s to be merged, must not be null.- Returns:
- See Also:
-
merge
Merges the currentLinks
with the given ones, skippingLink
s already contained in the current instance. For unconditional combination seeand(Iterable)
.- Parameters:
links
- theLink
s to be merged, must not be null.- Returns:
- See Also:
-
merge
Merges the currentLinks
with the given ones applying the givenLinks.MergeMode
.- Parameters:
mode
- must not be null.links
- must not be null.- Returns:
-
merge
Merges the currentLinks
with the given ones applying the givenLinks.MergeMode
.- Parameters:
mode
- must not be null.links
- must not be null.- Returns:
-
merge
Merges the currentLinks
with 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 aLink
with the given relation if contained in the currentLinks
instance,Optional.empty()
otherwise.- Parameters:
relation
- must not be null or empty.- Returns:
-
getLink
Returns theLink
with 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 theLink
with 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 theLink
with 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 theLinks
container is empty.- Returns:
-
hasSize
public boolean hasSize(long size) Returns whether the currentLinks
has 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()
-