(String[] args)
| 81 | |
| 82 | public class AStoreCADState { |
| 83 | public static void main(String[] args) { |
| 84 | List<Class<? extends Shape>> shapeTypes = |
| 85 | Arrays.asList( |
| 86 | Circle.class, Square.class, Line.class); |
| 87 | List<Shape> shapes = IntStream.range(0, 10) |
| 88 | .mapToObj(i -> Shape.randomFactory()) |
| 89 | .collect(Collectors.toList()); |
| 90 | // Set all the static colors to GREEN: |
| 91 | shapes.forEach(s -> s.setColor(Color.GREEN)); |
| 92 | // Save the state vector: |
| 93 | try( |
| 94 | ObjectOutputStream out = |
| 95 | new ObjectOutputStream( |
| 96 | new FileOutputStream("CADState.dat")) |
| 97 | ) { |
| 98 | out.writeObject(shapeTypes); |
| 99 | Line.serializeStaticState(out); |
| 100 | out.writeObject(shapes); |
| 101 | } catch(IOException e) { |
| 102 | throw new RuntimeException(e); |
| 103 | } |
| 104 | // Display the shapes: |
| 105 | System.out.println(shapes); |
| 106 | } |
| 107 | } |
| 108 | /* Output: |
| 109 | [class CircleColor[GREEN] xPos[58] yPos[55] dim[93] |
nothing calls this directly
no test coverage detected