@Override
    public void writeSpecialized(int i) {
        if (current == null) {
            current = i;
        } else {
            Integer currentI = this.ofSameTypeOrThrow(current, Integer.class);
            current = currentI + i;
        }
    }
@Test
    void invalidAddition() throws IOException {
        try (TypedObjectWriter writer = new TypedObjectWriter()){
            writer.writeSpecialized(1);
            IllegalArgumentException illegalArgumentException = Assertions.assertThrows(IllegalArgumentException.class, () -> writer.writeSpecialized('a'));
            assertThat(illegalArgumentException.getMessage(), is("Tried to add java.lang.Character to java.lang.Integer"));
        }
    }