mvn spring-boot:run -Dspring-boot.run.arguments="$1 $2"
mvn spring-boot:run -Dspring-boot.run.arguments="iJhz 5432"
[ {
"id" : "iJhz",
"destination_id" : 5432,
"name" : "Beach Villas Singapore",
"location" : {
"lat" : 1.264751,
"lng" : 103.824006,
"address" : "8 Sentosa Gateway, Beach Villas, 098269",
"city" : "Singapore",
"country" : "Singapore"
},
"description" : "Located at the western tip of Resorts World Sentosa, guests at the Beach Villas are guaranteed privacy while they enjoy spectacular views of glittering waters. G
uests will find themselves in paradise with this series of exquisite tropical sanctuaries, making it the perfect setting for an idyllic retreat. Within each villa, guests will disc
over living areas and bedrooms that open out to mini gardens, private timber sundecks and verandahs elegantly framing either lush greenery or an expanse of sea. Guests are assured
of a superior slumber with goose feather pillows and luxe mattresses paired with 400 thread count Egyptian cotton bed linen, tastefully paired with a full complement of luxurious i
n-room amenities and bathrooms boasting rain showers and free-standing tubs coupled with an exclusive array of ESPA amenities and toiletries. Guests also get to enjoy complimentary day access to the facilities at Asia?s flagship spa ? the world-renowned ESPA.",
"amenities" : {
"general" : [ "indoor pool", "outdoor pool", "business center", "dry cleaning", "childcare", "pool", "wi fi", "breakfast" ],
"room" : [ "tub", "tv", "iron", "aircon", "hair dryer", "coffee machine", "kettle" ]
},
"images" : {
"rooms" : [ {
"link" : "https://d2ey9sqrvkqdfs.cloudfront.net/0qZF/3.jpg",
"description" : "Double room"
}, {
"link" : "https://d2ey9sqrvkqdfs.cloudfront.net/0qZF/4.jpg",
"description" : "Bathroom"
}, {
"link" : "https://d2ey9sqrvkqdfs.cloudfront.net/0qZF/2.jpg",
"description" : "Double room"
} ],
"site" : [ {
"link" : "https://d2ey9sqrvkqdfs.cloudfront.net/0qZF/1.jpg",
"description" : "Front"
} ],
"amenities" : [ {
"link" : "https://d2ey9sqrvkqdfs.cloudfront.net/0qZF/6.jpg",
"description" : "Sentosa Gateway"
}, {
"link" : "https://d2ey9sqrvkqdfs.cloudfront.net/0qZF/0.jpg",
"description" : "RWS"
} ]
},
"booking_conditions" : [ "Guests are required to show a photo identification and credit card upon check-in. Please note that all Special Requests are subject to availability and
additional charges may apply. Payment before arrival via bank transfer is required. The property will contact you after you book to provide instructions. Please note that the full
amount of the reservation is due before arrival. Resorts World Sentosa will send a confirmation with detailed payment information. After full payment is taken, the property's detai
ls, including the address and where to collect keys, will be emailed to you. Bag checks will be conducted prior to entry to Adventure Cove Waterpark. === Upon check-in, guests will
be provided with complimentary Sentosa Pass (monorail) to enjoy unlimited transportation between Sentosa Island and Harbour Front (VivoCity). === Prepayment for non refundable boo
kings will be charged by RWS Call Centre. === All guests can enjoy complimentary parking during their stay, limited to one exit from the hotel per day. === Room reservation charges
will be charged upon check-in. Credit card provided upon reservation is for guarantee purpose. === For reservations made with inclusive breakfast, please note that breakfast is ap
plicable only for number of adults paid in the room rate. Any children or additional adults are charged separately for breakfast and are to paid directly to the hotel.", "Free priv
ate parking is possible on site (reservation is not needed).", "Pets are not allowed.", "All children are welcome. One child under 12 years stays free of charge when using existing
beds. One child under 2 years stays free of charge in a child's cot/crib. One child under 4 years stays free of charge when using existing beds. One older child or adult is charge
d SGD 82.39 per person per night in an extra bed. The maximum number of children's cots/cribs in a room is 1. There is no capacity for extra beds in the room.", "WiFi is available in all areas and is free of charge." ]
} ]
- An abstract
BaseSupplierclass and subclasses likeAcmeSupplier,PatagoniaSupplier,PaperfliesSupplier - These suppliers are required to implement
endpoint()(the api url of the supplier) andparse()(converting data from the api intoHotelobject) - These suppliers are automatically registered through
SupplierFactory, allowing for easy addition or management of suppliers
- Containing detailed information about the hotel, including
name,location,amenities,images. These attributes can be merged between hotels if they have the sameid. - The
Hotelclass also implements theMergeableinterface to support merging information from otherHotelobjects. Subclasses likeAmenities,Location,Imagesalso support similar merging behavior.
- The suppliers fetch data from external APIs. The data is then parsed and converted into
Hotelobjects throughparse()method
- After collecting data from all the suppliers, using
mergeAndSave()method inHotelServiceclass to merge hotels with the sameid. - This method uses a
Map<String,Hotel>to store hotels by theirid. If the new hotel has anidthat already exists in the map, it calls themerge()method of theHotelobject to combine data. The merging process ensures that all the non-null attributes of the new hotel will be updated in the existing hotel. - If the hotel does not exist in the map, it is added to the map.
- When a request to search for the hotels , the
HotelServiceclass provides thefind()method to filter hotels byhotelIdsanddestinationIds. The filtered hotels are returned as a list, allowing to search based on criteria.
- Using
Supplierclasses andSupplierFactoryallows the system to be easily extended. We can add new suppliers without changing the core of structure of the application -simple create a newSupplierclass and register it throughSupplierFactory
- The data merging process ensures that hotels from different suppliers are combined accurately and completely. If there are discrepancies between different versions of the same hotel, the new data will be fill in missing fields or update existing fields with new values.
- Easy to manage and maintain :
- By separating the responsibilities of each class (e.g., the
BaseSupplierclass only fetches data, while theHotelServiceclass handles merging and searching), the code is easier to maintain and extend.
- By separating the responsibilities of each class (e.g., the