@SneakyThrows
    @Override
    public void write(Object o) {
        if (current == null) {
            current = o;
        } else {
            throwIllegalAddition(current, o.getClass());
        }
    }
@Test
    void writeObjects() throws IOException {
        try (TypedObjectWriter writer = new TypedObjectWriter()){
            writer.write(Map.of("a", "b"));
            IllegalArgumentException illegalArgumentException = Assertions.assertThrows(IllegalArgumentException.class, () -> writer.write(Map.of("c", "d")));
            assertThat(illegalArgumentException.getMessage(), is("Tried to add java.util.ImmutableCollections$Map1 to java.util.ImmutableCollections$Map1"));
        }
    }