class ReservationBodyReader implements MessageBodyReader<Reservation> {

    @Override
    public Reservation readFrom(Class<Reservation> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
        JsonReader reader = Json.createReader(entityStream);

        JsonObject jsonObject = reader.readObject();

        DateTimeFormatter formatter = ofPattern("yyyy-MM-dd");
        LocalDate checkin = parse(requireNonNull(jsonObject.getString(CHECKINDATE.fieldName())), formatter);
        LocalDate checkout = parse(requireNonNull(jsonObject.getString(CHECKOUTDATE.fieldName())), formatter);

        BigDecimal cost = null;
        if (null == jsonObject.getJsonNumber(COSTSINEURO.fieldName())) {
            cost = reservationCostCalculator.calculateRateFor(STANDARD, checkin, checkout);
        } else {
            cost = jsonObject.getJsonNumber(COSTSINEURO.fieldName()).bigDecimalValue();
        }

        return new Reservation(requireNonNull(jsonObject.getString(GUESTID.fieldName())),
                jsonObject.getString(RESERVATIONNUMBER.fieldName(), ""),
                requireNonNull(jsonObject.getString(ASSIGNEDROOMID.fieldName())),
                checkin,
                checkout,
                cost);
    }

    public  ReservationBodyReader();
    @Inject public  ReservationBodyReader(ReservationCostCalculator reservationCostCalculator);

}