1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| log.info("Constrcting parts and card");
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 carProperties = Map.of( Property.MODEL.toString(), "300SL", Property.PRICE.toString(), 10000L, Property.PARTS.toString(), List.of(wheelProperties,doorProperties) );
var car = new Car((carProperties));
log.info("这是我们的车:"); log.info("-> model : {}",car.getModel().orElseThrow()); log.info("-> price : {}",car.getPrice().orElseThrow()); log.info("-> parts : "); car.getParts().forEach(p -> log.info("\t{}/{}/{}", p.getType().orElse(null), p.getModel().orElse(null), p.getPrice().orElse(null) ));
|