// Path: src/main/java/org/letustakearest/domain/Booking.java
// @Getter
// @Setter
// public final class Booking extends IdentifiableAndVersioned {
// 
//     private User user;
// 
//     private Place place;
// 
//     private LocalDate checkIn;
// 
//     private LocalDate checkOut;
// 
//     private boolean includeBreakfast;
// 
//     private BigDecimal price;
// 
//     private State state;
// 
//     private Payment payment;
// 
//     /**
//      * @author volodymyr.tsukur
//      */
//     public enum State {
// 
//         CREATED,
// 
//         PAID,
// 
//         SERVED,
// 
//         CANCELLED
// 
//     }
// 
// }
// 
// Path: src/main/java/org/letustakearest/presentation/resources/BookingsResource.java
// @Path("/bookings")
// public class BookingsResource {
// 
//     @Inject
//     private BookingService bookingService;
// 
//     @Context
//     private ResourceContext resourceContext;
// 
//     @Inject
//     @SelectByAcceptHeader
//     private BookingsRepresentationAssembler bookingsRepresentationAssembler;
// 
//     @GET
//     @Produces({ RepresentationFactory.HAL_JSON, Siren4J.JSON_MEDIATYPE })
//     public Response browse() {
//         return Response.
//                 ok(bookingsRepresentationAssembler.from(bookingService.findAll())).
//                 cacheControl(CacheControl.valueOf("max-age=" + Duration.ofMinutes(1).getSeconds())).
//                 build();
//     }
// 
//     @POST
//     @Produces({ RepresentationFactory.HAL_JSON, Siren4J.JSON_MEDIATYPE })
//     @Consumes("application/json")
//     public Response create(final CreateBookingAsPlaceTransition transition, @Context final UriInfo uriInfo) {
//         final Booking result;
//         try {
//             result = bookingService.create(transition);
//         } catch (EntityNotFoundException e) {
//             throw new WebApplicationException(Response.Status.BAD_REQUEST);
//         }
//         final URI bookingURI = BookingResource.selfURI(result, uriInfo);
//         return Response.created(bookingURI).build();
//     }
// 
//     @Path("/{id}")
//     public BookingResource item() {
//         return resourceContext.getResource(BookingResource.class);
//     }
// 
//     public static URI selfURI(final UriInfo uriInfo) {
//         return uriInfo.getBaseUriBuilder().
//                 path(BookingsResource.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.domain.Booking;
import org.letustakearest.presentation.resources.BookingsResource;
import javax.ws.rs.core.UriInfo;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
package org.letustakearest.presentation.representations.siren;



/**
 * @author volodymyr.tsukur
 */
class BookingsRepresentationBuilder {

    private final Collection<Booking> bookings;

    private final UriInfo uriInfo;

    public BookingsRepresentationBuilder(final Collection<Booking> bookings, final UriInfo uriInfo) {
        this.bookings = bookings;
        this.uriInfo = uriInfo;
    }

    public Entity build() {
        return EntityBuilder.newInstance().
                setComponentClass("bookings").
                addSubEntities(bookings()).
                addLink(LinkBuilder.newInstance().
                        setHref(selfHref()).
                        setRelationship(Link.RELATIONSHIP_SELF).
                        build()).build();
    }

    private List<Entity> bookings() {
// Path: src/main/java/org/letustakearest/domain/Booking.java
// @Getter
// @Setter
// public final class Booking extends IdentifiableAndVersioned {
// 
//     private User user;
// 
//     private Place place;
// 
//     private LocalDate checkIn;
// 
//     private LocalDate checkOut;
// 
//     private boolean includeBreakfast;
// 
//     private BigDecimal price;
// 
//     private State state;
// 
//     private Payment payment;
// 
//     /**
//      * @author volodymyr.tsukur
//      */
//     public enum State {
// 
//         CREATED,
// 
//         PAID,
// 
//         SERVED,
// 
//         CANCELLED
// 
//     }
// 
// }
// 
// Path: src/main/java/org/letustakearest/presentation/resources/BookingsResource.java
// @Path("/bookings")
// public class BookingsResource {
// 
//     @Inject
//     private BookingService bookingService;
// 
//     @Context
//     private ResourceContext resourceContext;
// 
//     @Inject
//     @SelectByAcceptHeader
//     private BookingsRepresentationAssembler bookingsRepresentationAssembler;
// 
//     @GET
//     @Produces({ RepresentationFactory.HAL_JSON, Siren4J.JSON_MEDIATYPE })
//     public Response browse() {
//         return Response.
//                 ok(bookingsRepresentationAssembler.from(bookingService.findAll())).
//                 cacheControl(CacheControl.valueOf("max-age=" + Duration.ofMinutes(1).getSeconds())).
//                 build();
//     }
// 
//     @POST
//     @Produces({ RepresentationFactory.HAL_JSON, Siren4J.JSON_MEDIATYPE })
//     @Consumes("application/json")
//     public Response create(final CreateBookingAsPlaceTransition transition, @Context final UriInfo uriInfo) {
//         final Booking result;
//         try {
//             result = bookingService.create(transition);
//         } catch (EntityNotFoundException e) {
//             throw new WebApplicationException(Response.Status.BAD_REQUEST);
//         }
//         final URI bookingURI = BookingResource.selfURI(result, uriInfo);
//         return Response.created(bookingURI).build();
//     }
// 
//     @Path("/{id}")
//     public BookingResource item() {
//         return resourceContext.getResource(BookingResource.class);
//     }
// 
//     public static URI selfURI(final UriInfo uriInfo) {
//         return uriInfo.getBaseUriBuilder().
//                 path(BookingsResource.class).
//                 build();
//     }
// 
// }


// Path: src/main/java/org/letustakearest/presentation/representations/siren/BookingsRepresentationBuilder.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.domain.Booking;
import org.letustakearest.presentation.resources.BookingsResource;
import javax.ws.rs.core.UriInfo;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

package org.letustakearest.presentation.representations.siren;



/**
 * @author volodymyr.tsukur
 */
class BookingsRepresentationBuilder {

    private final Collection<Booking> bookings;

    private final UriInfo uriInfo;

    public BookingsRepresentationBuilder(final Collection<Booking> bookings, final UriInfo uriInfo) {
        this.bookings = bookings;
        this.uriInfo = uriInfo;
    }

    public Entity build() {
        return EntityBuilder.newInstance().
                setComponentClass("bookings").
                addSubEntities(bookings()).
                addLink(LinkBuilder.newInstance().
                        setHref(selfHref()).
                        setRelationship(Link.RELATIONSHIP_SELF).
                        build()).build();
    }

    private List<Entity> bookings() {
        return bookings.stream().