mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-14 00:16:48 +00:00
docs: update abstract document
This commit is contained in:
1 parent
31f0f5a904
commit
6ccf6104ac
1 file changed
+9
-2
@@ -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,6 +133,7 @@ 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
|
||||||
|
public static void main(String[] args) {
|
||||||
LOGGER.info("Constructing parts and car");
|
LOGGER.info("Constructing parts and car");
|
||||||
|
|
||||||
var wheelProperties = Map.of(
|
var wheelProperties = Map.of(
|
||||||
@@ -155,7 +157,12 @@ 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:
|
||||||
|
|||||||
Reference in new issue
Block a user