docs: update abstract document

This commit is contained in:
Ilkka Seppälä
2024-05-24 09:32:51 +03:00
parent 31f0f5a904
commit 6ccf6104ac
+27 -20
View File
@@ -77,7 +77,8 @@ public abstract class AbstractDocument implements Document {
.flatMap(Collection::stream) .flatMap(Collection::stream)
.map(constructor); .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. And finally here's how we construct and use the `Car` in a full example.
```java ```java
LOGGER.info("Constructing parts and car"); public static void main(String[] args) {
LOGGER.info("Constructing parts and car");
var wheelProperties = Map.of( var wheelProperties = Map.of(
Property.TYPE.toString(), "wheel", Property.TYPE.toString(), "wheel",
Property.MODEL.toString(), "15C", Property.MODEL.toString(), "15C",
Property.PRICE.toString(), 100L); Property.PRICE.toString(), 100L);
var doorProperties = Map.of( var doorProperties = Map.of(
Property.TYPE.toString(), "door", Property.TYPE.toString(), "door",
Property.MODEL.toString(), "Lambo", Property.MODEL.toString(), "Lambo",
Property.PRICE.toString(), 300L); Property.PRICE.toString(), 300L);
var carProperties = Map.of( var carProperties = Map.of(
Property.MODEL.toString(), "300SL", Property.MODEL.toString(), "300SL",
Property.PRICE.toString(), 10000L, Property.PRICE.toString(), 10000L,
Property.PARTS.toString(), List.of(wheelProperties, doorProperties)); 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("Here is our car:");
LOGGER.info("-> model: {}", car.getModel().orElseThrow()); LOGGER.info("-> model: {}", car.getModel().orElseThrow());
LOGGER.info("-> price: {}", car.getPrice().orElseThrow()); LOGGER.info("-> price: {}", car.getPrice().orElseThrow());
LOGGER.info("-> parts: "); LOGGER.info("-> parts: ");
car.getParts().forEach(p -> LOGGER.info("\t{}/{}/{}", p.getType().orElse(null), p.getModel().orElse(null), p.getPrice().orElse(null))); car.getParts().forEach(p -> LOGGER.info("\t{}/{}/{}",
p.getType().orElse(null),
p.getModel().orElse(null),
p.getPrice().orElse(null))
);
}
``` ```
The program output: The program output: