From 6ccf6104ac3a522f45894532efd0d7a7c99dbeb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Fri, 24 May 2024 09:32:51 +0300 Subject: [PATCH] docs: update abstract document --- abstract-document/README.md | 47 +++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/abstract-document/README.md b/abstract-document/README.md index e5bb1889f..358e0915e 100644 --- a/abstract-document/README.md +++ b/abstract-document/README.md @@ -77,7 +77,8 @@ public abstract class AbstractDocument implements Document { .flatMap(Collection::stream) .map(constructor); } - ... + + // Other properties and methods... } ``` @@ -132,30 +133,36 @@ public class Car extends AbstractDocument implements HasModel, HasPrice, HasPart And finally here's how we construct and use the `Car` in a full example. ```java -LOGGER.info("Constructing parts and car"); + public static void main(String[] args) { + LOGGER.info("Constructing parts and car"); -var wheelProperties = Map.of( - Property.TYPE.toString(), "wheel", - Property.MODEL.toString(), "15C", - Property.PRICE.toString(), 100L); + var wheelProperties = Map.of( + Property.TYPE.toString(), "wheel", + Property.MODEL.toString(), "15C", + Property.PRICE.toString(), 100L); -var doorProperties = Map.of( - Property.TYPE.toString(), "door", - Property.MODEL.toString(), "Lambo", - Property.PRICE.toString(), 300L); + var doorProperties = Map.of( + Property.TYPE.toString(), "door", + Property.MODEL.toString(), "Lambo", + Property.PRICE.toString(), 300L); -var carProperties = Map.of( - Property.MODEL.toString(), "300SL", - Property.PRICE.toString(), 10000L, - Property.PARTS.toString(), List.of(wheelProperties, doorProperties)); + var carProperties = Map.of( + Property.MODEL.toString(), "300SL", + Property.PRICE.toString(), 10000L, + Property.PARTS.toString(), List.of(wheelProperties, doorProperties)); -var car = new Car(carProperties); + var car = new Car(carProperties); -LOGGER.info("Here is our car:"); -LOGGER.info("-> model: {}", car.getModel().orElseThrow()); -LOGGER.info("-> price: {}", car.getPrice().orElseThrow()); -LOGGER.info("-> parts: "); -car.getParts().forEach(p -> LOGGER.info("\t{}/{}/{}", p.getType().orElse(null), p.getModel().orElse(null), p.getPrice().orElse(null))); + LOGGER.info("Here is our car:"); + LOGGER.info("-> model: {}", car.getModel().orElseThrow()); + LOGGER.info("-> price: {}", car.getPrice().orElseThrow()); + LOGGER.info("-> parts: "); + car.getParts().forEach(p -> LOGGER.info("\t{}/{}/{}", + p.getType().orElse(null), + p.getModel().orElse(null), + p.getPrice().orElse(null)) + ); +} ``` The program output: