// Path: src/main/java/org/letustakearest/application/service/Pagination.java
// @Getter
// public final class Pagination {
// 
//     private int offset;
// 
//     private int limit;
// 
//     public Pagination(final int offset, final int limit) {
//         this.offset = offset;
//         this.limit = limit;
//     }
// 
//     public static final Pagination DEFAULT = new Pagination(0, 2);
// 
//     public static Pagination getPagination(final Integer offset, final Integer limit) {
//         return new Pagination(offset == null ? DEFAULT.offset : offset, limit == null ? DEFAULT.limit : limit);
//     }
// 
// }
// 
// Path: src/main/java/org/letustakearest/domain/Hotel.java
// @Getter
// @Setter
// public final class Hotel extends IdentifiableAndVersioned {
// 
//     private City city;
// 
//     private String name;
// 
//     private Set<Place> places = new HashSet<>();
// 
// }
// 
// Path: src/main/java/org/letustakearest/domain/PaginatedResult.java
// @Getter
// public final class PaginatedResult<E extends IdentifiableAndVersioned> {
// 
//     private final List<E> list;
// 
//     private final Pagination actualPagination;
// 
//     private final int total;
// 
//     public PaginatedResult(final List<E> list, final Pagination actualPagination, final int total) {
//         this.list = list;
//         this.actualPagination = actualPagination;
//         this.total = total;
//     }
// 
// }
// 
// Path: src/main/java/org/letustakearest/presentation/resources/HotelsResource.java
// @Path("/hotels")
// public class HotelsResource {
// 
//     @Context
//     private ResourceContext resourceContext;
// 
//     @Inject
//     private HotelService hotelService;
// 
//     @Inject @SelectByAcceptHeader
//     private HotelsRepresentationAssembler hotelsRepresentationAssembler;
// 
//     @GET
//     @Produces({ RepresentationFactory.HAL_JSON, Siren4J.JSON_MEDIATYPE })
//     public Response browse(
//             @QueryParam("offset") final Integer offset,
//             @QueryParam("limit") final Integer limit) {
//         final Pagination pagination = Pagination.getPagination(offset, limit);
//         return Response.ok(
//                 hotelsRepresentationAssembler.from(hotelService.findSeveral(pagination))).
//                 build();
//     }
// 
//     @Path("/{id}")
//     public HotelResource item(@PathParam("id") final Long id) {
//         return resourceContext.getResource(HotelResource.class);
//     }
// 
//     public static URI selfURI(final UriInfo uriInfo) {
//         return uriInfo.getBaseUriBuilder().
//                 path(HotelsResource.class).
//                 build();
//     }
// 
// }


import com.google.code.siren4j.component.Entity;
import com.google.code.siren4j.component.Link;
import com.google.code.siren4j.component.builder.EntityBuilder;
import com.google.code.siren4j.component.builder.LinkBuilder;
import org.letustakearest.application.service.Pagination;
import org.letustakearest.domain.Hotel;
import org.letustakearest.domain.PaginatedResult;
import org.letustakearest.presentation.resources.HotelsResource;
import javax.ws.rs.core.UriInfo;
import java.util.List;
import java.util.stream.Collectors;

    private List<Entity> hotels() {
        return hotels.getList().stream().
                map(hotel -> new HotelEmbeddedRepresentationBuilder(hotel, uriInfo).build()).
                collect(Collectors.toList());
    }

    private EntityBuilder addNextLinkIfRequired(final EntityBuilder builder) {
        final int nextOffset = hotels.getActualPagination().getOffset() + Pagination.DEFAULT.getLimit();
        if (nextOffset < hotels.getTotal()) {
            return builder.addLink(LinkBuilder.newInstance().
                    setHref(hrefWithOffset(nextOffset)).
                    setComponentClass("hotels").
                    setRelationship(Link.RELATIONSHIP_NEXT).
                    build());
        }
        else {
            return builder;
        }
    }

    private EntityBuilder addPrevLinkIfRequired(final EntityBuilder builder) {
        if (hotels.getActualPagination().getOffset() > 0) {
            final int prevOffset = Math.max(hotels.getActualPagination().getOffset() - Pagination.DEFAULT.getLimit(), 0);
            return builder.addLink(LinkBuilder.newInstance().
                    setHref(hrefWithOffset(prevOffset)).
                    setComponentClass("hotels").
                    setRelationship(Link.RELATIONSHIP_PREVIOUS).
                    build());
        }
// Path: src/main/java/org/letustakearest/application/service/Pagination.java
// @Getter
// public final class Pagination {
// 
//     private int offset;
// 
//     private int limit;
// 
//     public Pagination(final int offset, final int limit) {
//         this.offset = offset;
//         this.limit = limit;
//     }
// 
//     public static final Pagination DEFAULT = new Pagination(0, 2);
// 
//     public static Pagination getPagination(final Integer offset, final Integer limit) {
//         return new Pagination(offset == null ? DEFAULT.offset : offset, limit == null ? DEFAULT.limit : limit);
//     }
// 
// }
// 
// Path: src/main/java/org/letustakearest/domain/Hotel.java
// @Getter
// @Setter
// public final class Hotel extends IdentifiableAndVersioned {
// 
//     private City city;
// 
//     private String name;
// 
//     private Set<Place> places = new HashSet<>();
// 
// }
// 
// Path: src/main/java/org/letustakearest/domain/PaginatedResult.java
// @Getter
// public final class PaginatedResult<E extends IdentifiableAndVersioned> {
// 
//     private final List<E> list;
// 
//     private final Pagination actualPagination;
// 
//     private final int total;
// 
//     public PaginatedResult(final List<E> list, final Pagination actualPagination, final int total) {
//         this.list = list;
//         this.actualPagination = actualPagination;
//         this.total = total;
//     }
// 
// }
// 
// Path: src/main/java/org/letustakearest/presentation/resources/HotelsResource.java
// @Path("/hotels")
// public class HotelsResource {
// 
//     @Context
//     private ResourceContext resourceContext;
// 
//     @Inject
//     private HotelService hotelService;
// 
//     @Inject @SelectByAcceptHeader
//     private HotelsRepresentationAssembler hotelsRepresentationAssembler;
// 
//     @GET
//     @Produces({ RepresentationFactory.HAL_JSON, Siren4J.JSON_MEDIATYPE })
//     public Response browse(
//             @QueryParam("offset") final Integer offset,
//             @QueryParam("limit") final Integer limit) {
//         final Pagination pagination = Pagination.getPagination(offset, limit);
//         return Response.ok(
//                 hotelsRepresentationAssembler.from(hotelService.findSeveral(pagination))).
//                 build();
//     }
// 
//     @Path("/{id}")
//     public HotelResource item(@PathParam("id") final Long id) {
//         return resourceContext.getResource(HotelResource.class);
//     }
// 
//     public static URI selfURI(final UriInfo uriInfo) {
//         return uriInfo.getBaseUriBuilder().
//                 path(HotelsResource.class).
//                 build();
//     }
// 
// }


// Path: src/main/java/org/letustakearest/presentation/representations/siren/HotelsRepresentationBuilder.java
import com.google.code.siren4j.component.Entity;
import com.google.code.siren4j.component.Link;
import com.google.code.siren4j.component.builder.EntityBuilder;
import com.google.code.siren4j.component.builder.LinkBuilder;
import org.letustakearest.application.service.Pagination;
import org.letustakearest.domain.Hotel;
import org.letustakearest.domain.PaginatedResult;
import org.letustakearest.presentation.resources.HotelsResource;
import javax.ws.rs.core.UriInfo;
import java.util.List;
import java.util.stream.Collectors;


    private List<Entity> hotels() {
        return hotels.getList().stream().
                map(hotel -> new HotelEmbeddedRepresentationBuilder(hotel, uriInfo).build()).
                collect(Collectors.toList());
    }

    private EntityBuilder addNextLinkIfRequired(final EntityBuilder builder) {
        final int nextOffset = hotels.getActualPagination().getOffset() + Pagination.DEFAULT.getLimit();
        if (nextOffset < hotels.getTotal()) {
            return builder.addLink(LinkBuilder.newInstance().
                    setHref(hrefWithOffset(nextOffset)).
                    setComponentClass("hotels").
                    setRelationship(Link.RELATIONSHIP_NEXT).
                    build());
        }
        else {
            return builder;
        }
    }

    private EntityBuilder addPrevLinkIfRequired(final EntityBuilder builder) {
        if (hotels.getActualPagination().getOffset() > 0) {
            final int prevOffset = Math.max(hotels.getActualPagination().getOffset() - Pagination.DEFAULT.getLimit(), 0);
            return builder.addLink(LinkBuilder.newInstance().
                    setHref(hrefWithOffset(prevOffset)).
                    setComponentClass("hotels").
                    setRelationship(Link.RELATIONSHIP_PREVIOUS).
                    build());
        }
        else {