Class 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 Detail

      • classes

        public SirenModelBuilder classes​(@NonNull
                                         @NonNull String... classes)
        Adds the given classes to the RepresentationModel 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
      • properties

        public SirenModelBuilder properties​(@NonNull
                                            @NonNull Object properties)
        Adds the given properties to the RepresentationModel 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 String rel,
                                          @NonNull
                                          @NonNull Object entity)
        Adds the given entity to the RepresentationModel to 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 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 the RepresentationModel to 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 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 the RepresentationModel to 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 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 the RepresentationModel to 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 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 the RepresentationModel to 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 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 the RepresentationModel to 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 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 the RepresentationModel 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 the RepresentationModel 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 the RepresentationModel 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 the RepresentationModel 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 a RepresentationModel based on the content hold in this SirenModelBuilder instance.
        Returns:
        will never be null.