Class SirenModelBuilder
- java.lang.Object
-
- de.ingogriebsch.spring.hateoas.siren.SirenModelBuilder
-
public final class SirenModelBuilder extends Object
A builder that allows to build complex Siren entity structures.- Since:
- 1.0.0
- Author:
- Ingo Griebsch
- See Also:
SirenModel
, Siren Entity
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.hateoas.RepresentationModel<?>
build()
Builds aRepresentationModel
based on the content hold in thisSirenModelBuilder
instance.SirenModelBuilder
classes(@NonNull Iterable<String> classes)
Adds the given classes to theRepresentationModel
to be built.SirenModelBuilder
classes(@NonNull String... classes)
Adds the given classes to theRepresentationModel
to be built.SirenModelBuilder
entities(@NonNull Iterable<?> entities)
Adds the given entities to theRepresentationModel
to be built.SirenModelBuilder
entities(@NonNull Object entity)
Adds the given entity to theRepresentationModel
to be built.SirenModelBuilder
entities(@NonNull Object... entities)
Adds the given entities to theRepresentationModel
to be built.SirenModelBuilder
entities(@NonNull String rel, @NonNull Iterable<?> entities)
Adds the given entities to theRepresentationModel
to be built.SirenModelBuilder
entities(@NonNull String rel, @NonNull Object entity)
Adds the given entity to theRepresentationModel
to be built.SirenModelBuilder
entities(@NonNull String rel, @NonNull Object... entities)
Adds the given entities to theRepresentationModel
to be built.SirenModelBuilder
entities(@NonNull org.springframework.hateoas.LinkRelation rel, @NonNull Iterable<?> entities)
Adds the given entities to theRepresentationModel
to be built.SirenModelBuilder
entities(@NonNull org.springframework.hateoas.LinkRelation rel, @NonNull Object entity)
Adds the given entity to theRepresentationModel
to be built.SirenModelBuilder
entities(@NonNull org.springframework.hateoas.LinkRelation rel, @NonNull Object... entities)
Adds the given entities to theRepresentationModel
to be built.SirenModelBuilder
linksAndActions(@NonNull Iterable<org.springframework.hateoas.Link> links)
Adds the given links to theRepresentationModel
to be built.SirenModelBuilder
linksAndActions(@NonNull org.springframework.hateoas.Link link)
Adds the given link to theRepresentationModel
to be built.SirenModelBuilder
linksAndActions(@NonNull org.springframework.hateoas.Link... links)
Adds the given links to theRepresentationModel
to be built.SirenModelBuilder
linksAndActions(@NonNull org.springframework.hateoas.Links links)
Adds the given links to theRepresentationModel
to be built.SirenModelBuilder
properties(@NonNull Object properties)
Adds the given properties to theRepresentationModel
to be built.static SirenModelBuilder
sirenModel()
Creates a newSirenModelBuilder
.SirenModelBuilder
title(@NonNull String title)
Adds the given title to theRepresentationModel
to be built.
-
-
-
Method Detail
-
sirenModel
public static SirenModelBuilder sirenModel()
Creates a newSirenModelBuilder
.- Returns:
- the created
SirenModelBuilder
instance.
-
classes
public SirenModelBuilder classes(@NonNull @NonNull String... classes)
Adds the given classes to theRepresentationModel
to be built.- Parameters:
classes
- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Entity Class
-
classes
public SirenModelBuilder classes(@NonNull @NonNull Iterable<String> classes)
Adds the given classes to theRepresentationModel
to be built.- Parameters:
classes
- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Entity Class
-
title
public SirenModelBuilder title(@NonNull @NonNull String title)
Adds the given title to theRepresentationModel
to be built.- Parameters:
title
- must not be null.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Entity Title
-
properties
public SirenModelBuilder properties(@NonNull @NonNull Object properties)
Adds the given properties to theRepresentationModel
to be built.- Parameters:
properties
- must not be null and must not be of type RepresentationModel.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Entity Properties
-
entities
public SirenModelBuilder entities(@NonNull @NonNull Object entity)
Adds the given entity to theRepresentationModel
to be built.The entity will be wrapped into an appropriate
RepresentationModel
if necessary. The relation to its parent will be evaluated through the configuredSirenEntityRelProvider
.- Parameters:
entity
- must not be null.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Entities, Siren Embedded Representation
-
entities
public SirenModelBuilder entities(@NonNull @NonNull Object... entities)
Adds the given entities to theRepresentationModel
to be built.The entities will be wrapped into appropriate
RepresentationModel
s if necessary. The relation to its parent will be evaluated through the configuredSirenEntityRelProvider
.- Parameters:
entities
- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Entities, Siren Embedded Representation
-
entities
public SirenModelBuilder entities(@NonNull @NonNull Iterable<?> entities)
Adds the given entities to theRepresentationModel
to be built.The entities will be wrapped into appropriate
RepresentationModel
s if necessary. The relation to its parent will be evaluated through the configuredSirenEntityRelProvider
.- Parameters:
entities
- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Entities, Siren Embedded Representation
-
entities
public SirenModelBuilder entities(@NonNull @NonNull String rel, @NonNull @NonNull Object entity)
Adds the given entity to theRepresentationModel
to be built.The entity will be wrapped into an appropriate
RepresentationModel
s if necessary. The relation to its parent is defined through the given rel.- Parameters:
rel
- must not be null.entity
- must not be null.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Entities, Siren Embedded Representation
-
entities
public SirenModelBuilder entities(@NonNull @NonNull String rel, @NonNull @NonNull Object... entities)
Adds the given entities to theRepresentationModel
to be built.The entities will be wrapped into appropriate
RepresentationModel
s if necessary. The relation to its parent is defined through the given rel.- Parameters:
rel
- must not be null.entities
- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Entities, Siren Embedded Representation
-
entities
public SirenModelBuilder entities(@NonNull @NonNull String rel, @NonNull @NonNull Iterable<?> entities)
Adds the given entities to theRepresentationModel
to be built.The entities will be wrapped into appropriate
RepresentationModel
s if necessary. The relation to its parent is defined through the given rel.- Parameters:
rel
- must not be null.entities
- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Entities, Siren Embedded Representation
-
entities
public SirenModelBuilder entities(@NonNull @NonNull org.springframework.hateoas.LinkRelation rel, @NonNull @NonNull Object entity)
Adds the given entity to theRepresentationModel
to be built.The entities will be wrapped into appropriate
RepresentationModel
s if necessary. The relation to its parent is defined through the given rel.- Parameters:
rel
- must not be null.entity
- must not be null.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Entities, Siren Embedded Representation
-
entities
public SirenModelBuilder entities(@NonNull @NonNull org.springframework.hateoas.LinkRelation rel, @NonNull @NonNull Object... entities)
Adds the given entities to theRepresentationModel
to be built.The entities will be wrapped into appropriate
RepresentationModel
s if necessary. The relation to its parent is defined through the given rel.- Parameters:
rel
- must not be null.entities
- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Entities, Siren Embedded Representation
-
entities
public SirenModelBuilder entities(@NonNull @NonNull org.springframework.hateoas.LinkRelation rel, @NonNull @NonNull Iterable<?> entities)
Adds the given entities to theRepresentationModel
to be built.The entities will be wrapped into appropriate
RepresentationModel
s if necessary. The relation to its parent is defined through the given rel.- Parameters:
rel
- must not be null.entities
- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Entities, Siren Embedded Representation
-
linksAndActions
public SirenModelBuilder linksAndActions(@NonNull @NonNull org.springframework.hateoas.Link link)
Adds the given link to theRepresentationModel
to be built.- Parameters:
link
- must not be null.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Link, Siren Action
-
linksAndActions
public SirenModelBuilder linksAndActions(@NonNull @NonNull org.springframework.hateoas.Link... links)
Adds the given links to theRepresentationModel
to be built.- Parameters:
links
- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Link, Siren Action
-
linksAndActions
public SirenModelBuilder linksAndActions(@NonNull @NonNull Iterable<org.springframework.hateoas.Link> links)
Adds the given links to theRepresentationModel
to be built.- Parameters:
links
- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Link, Siren Action
-
linksAndActions
public SirenModelBuilder linksAndActions(@NonNull @NonNull org.springframework.hateoas.Links links)
Adds the given links to theRepresentationModel
to be built.- Parameters:
links
- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilder
instance. - See Also:
- Siren Link, Siren Action
-
build
public org.springframework.hateoas.RepresentationModel<?> build()
Builds aRepresentationModel
based on the content hold in thisSirenModelBuilder
instance.- Returns:
- will never be null.
-
-