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 aRepresentationModelbased on the content hold in thisSirenModelBuilderinstance.SirenModelBuilderclasses(@NonNull Iterable<String> classes)Adds the given classes to theRepresentationModelto be built.SirenModelBuilderclasses(@NonNull String... classes)Adds the given classes to theRepresentationModelto be built.SirenModelBuilderentities(@NonNull Iterable<?> entities)Adds the given entities to theRepresentationModelto be built.SirenModelBuilderentities(@NonNull Object entity)Adds the given entity to theRepresentationModelto be built.SirenModelBuilderentities(@NonNull Object... entities)Adds the given entities to theRepresentationModelto be built.SirenModelBuilderentities(@NonNull String rel, @NonNull Iterable<?> entities)Adds the given entities to theRepresentationModelto be built.SirenModelBuilderentities(@NonNull String rel, @NonNull Object entity)Adds the given entity to theRepresentationModelto be built.SirenModelBuilderentities(@NonNull String rel, @NonNull Object... entities)Adds the given entities to theRepresentationModelto be built.SirenModelBuilderentities(@NonNull org.springframework.hateoas.LinkRelation rel, @NonNull Iterable<?> entities)Adds the given entities to theRepresentationModelto be built.SirenModelBuilderentities(@NonNull org.springframework.hateoas.LinkRelation rel, @NonNull Object entity)Adds the given entity to theRepresentationModelto be built.SirenModelBuilderentities(@NonNull org.springframework.hateoas.LinkRelation rel, @NonNull Object... entities)Adds the given entities to theRepresentationModelto be built.SirenModelBuilderlinksAndActions(@NonNull Iterable<org.springframework.hateoas.Link> links)Adds the given links to theRepresentationModelto be built.SirenModelBuilderlinksAndActions(@NonNull org.springframework.hateoas.Link link)Adds the given link to theRepresentationModelto be built.SirenModelBuilderlinksAndActions(@NonNull org.springframework.hateoas.Link... links)Adds the given links to theRepresentationModelto be built.SirenModelBuilderlinksAndActions(@NonNull org.springframework.hateoas.Links links)Adds the given links to theRepresentationModelto be built.SirenModelBuilderproperties(@NonNull Object properties)Adds the given properties to theRepresentationModelto be built.static SirenModelBuildersirenModel()Creates a newSirenModelBuilder.SirenModelBuildertitle(@NonNull String title)Adds the given title to theRepresentationModelto be built.
-
-
-
Method Detail
-
sirenModel
public static SirenModelBuilder sirenModel()
Creates a newSirenModelBuilder.- Returns:
- the created
SirenModelBuilderinstance.
-
classes
public SirenModelBuilder classes(@NonNull @NonNull String... classes)
Adds the given classes to theRepresentationModelto be built.- Parameters:
classes- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilderinstance. - See Also:
- Siren Entity Class
-
classes
public SirenModelBuilder classes(@NonNull @NonNull Iterable<String> classes)
Adds the given classes to theRepresentationModelto be built.- Parameters:
classes- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilderinstance. - See Also:
- Siren Entity Class
-
title
public SirenModelBuilder title(@NonNull @NonNull String title)
Adds the given title to theRepresentationModelto be built.- Parameters:
title- must not be null.- Returns:
- the current
SirenModelBuilderinstance. - See Also:
- Siren Entity Title
-
properties
public SirenModelBuilder properties(@NonNull @NonNull Object properties)
Adds the given properties to theRepresentationModelto be built.- Parameters:
properties- must not be null and must not be of type RepresentationModel.- Returns:
- the current
SirenModelBuilderinstance. - See Also:
- Siren Entity Properties
-
entities
public SirenModelBuilder entities(@NonNull @NonNull Object entity)
Adds the given entity to theRepresentationModelto be built.The entity will be wrapped into an appropriate
RepresentationModelif necessary. The relation to its parent will be evaluated through the configuredSirenEntityRelProvider.- Parameters:
entity- must not be null.- Returns:
- the current
SirenModelBuilderinstance. - See Also:
- Siren Entities, Siren Embedded Representation
-
entities
public SirenModelBuilder entities(@NonNull @NonNull Object... entities)
Adds the given entities to theRepresentationModelto be built.The entities will be wrapped into appropriate
RepresentationModels 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
SirenModelBuilderinstance. - See Also:
- Siren Entities, Siren Embedded Representation
-
entities
public SirenModelBuilder entities(@NonNull @NonNull Iterable<?> entities)
Adds the given entities to theRepresentationModelto be built.The entities will be wrapped into appropriate
RepresentationModels 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
SirenModelBuilderinstance. - See Also:
- Siren Entities, Siren Embedded Representation
-
entities
public SirenModelBuilder entities(@NonNull @NonNull String rel, @NonNull @NonNull Object entity)
Adds the given entity to theRepresentationModelto be built.The entity will be wrapped into an appropriate
RepresentationModels 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
SirenModelBuilderinstance. - See Also:
- Siren Entities, Siren Embedded Representation
-
entities
public SirenModelBuilder entities(@NonNull @NonNull String rel, @NonNull @NonNull Object... entities)
Adds the given entities to theRepresentationModelto be built.The entities will be wrapped into appropriate
RepresentationModels 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
SirenModelBuilderinstance. - See Also:
- Siren Entities, Siren Embedded Representation
-
entities
public SirenModelBuilder entities(@NonNull @NonNull String rel, @NonNull @NonNull Iterable<?> entities)
Adds the given entities to theRepresentationModelto be built.The entities will be wrapped into appropriate
RepresentationModels 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
SirenModelBuilderinstance. - 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 theRepresentationModelto be built.The entities will be wrapped into appropriate
RepresentationModels 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
SirenModelBuilderinstance. - 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 theRepresentationModelto be built.The entities will be wrapped into appropriate
RepresentationModels 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
SirenModelBuilderinstance. - 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 theRepresentationModelto be built.The entities will be wrapped into appropriate
RepresentationModels 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
SirenModelBuilderinstance. - See Also:
- Siren Entities, Siren Embedded Representation
-
linksAndActions
public SirenModelBuilder linksAndActions(@NonNull @NonNull org.springframework.hateoas.Link link)
Adds the given link to theRepresentationModelto be built.- Parameters:
link- must not be null.- Returns:
- the current
SirenModelBuilderinstance. - See Also:
- Siren Link, Siren Action
-
linksAndActions
public SirenModelBuilder linksAndActions(@NonNull @NonNull org.springframework.hateoas.Link... links)
Adds the given links to theRepresentationModelto be built.- Parameters:
links- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilderinstance. - See Also:
- Siren Link, Siren Action
-
linksAndActions
public SirenModelBuilder linksAndActions(@NonNull @NonNull Iterable<org.springframework.hateoas.Link> links)
Adds the given links to theRepresentationModelto be built.- Parameters:
links- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilderinstance. - See Also:
- Siren Link, Siren Action
-
linksAndActions
public SirenModelBuilder linksAndActions(@NonNull @NonNull org.springframework.hateoas.Links links)
Adds the given links to theRepresentationModelto be built.- Parameters:
links- must not be null and must not contain null values.- Returns:
- the current
SirenModelBuilderinstance. - See Also:
- Siren Link, Siren Action
-
build
public org.springframework.hateoas.RepresentationModel<?> build()
Builds aRepresentationModelbased on the content hold in thisSirenModelBuilderinstance.- Returns:
- will never be null.
-
-