@Override
    public TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(
            TypeSerializerSnapshot<T> oldSerializerSnapshot) {
        if (!(oldSerializerSnapshot instanceof PojoSerializerSnapshot)) {
            return TypeSerializerSchemaCompatibility.incompatible();
        }

        PojoSerializerSnapshot<T> previousPojoSerializerSnapshot =
                (PojoSerializerSnapshot<T>) oldSerializerSnapshot;

        final Class<T> previousPojoClass =
                previousPojoSerializerSnapshot.snapshotData.getPojoClass();
        final LinkedOptionalMap<Field, TypeSerializerSnapshot<?>> fieldSerializerSnapshots =
                previousPojoSerializerSnapshot.snapshotData.getFieldSerializerSnapshots();
        final LinkedOptionalMap<Class<?>, TypeSerializerSnapshot<?>>
                registeredSubclassSerializerSnapshots =
                        previousPojoSerializerSnapshot.snapshotData
                                .getRegisteredSubclassSerializerSnapshots();
        final LinkedOptionalMap<Class<?>, TypeSerializerSnapshot<?>>
                nonRegisteredSubclassSerializerSnapshots =
                        previousPojoSerializerSnapshot.snapshotData
                                .getNonRegisteredSubclassSerializerSnapshots();

        if (previousPojoClass != snapshotData.getPojoClass()) {
            return TypeSerializerSchemaCompatibility.incompatible();
        }

        if (registeredSubclassSerializerSnapshots.hasAbsentKeysOrValues()) {
            return TypeSerializerSchemaCompatibility.incompatible();
        }

        if (nonRegisteredSubclassSerializerSnapshots.hasAbsentKeysOrValues()) {
            return TypeSerializerSchemaCompatibility.incompatible();
        }

        final IntermediateCompatibilityResult<T> preExistingFieldSerializersCompatibility =
                getCompatibilityOfPreExistingFields(fieldSerializerSnapshots);

        if (preExistingFieldSerializersCompatibility.isIncompatible()) {
            return TypeSerializerSchemaCompatibility.incompatible();
        }

        final IntermediateCompatibilityResult<T> preExistingRegistrationsCompatibility =
                getCompatibilityOfPreExistingRegisteredSubclasses(
                        registeredSubclassSerializerSnapshots);

        if (preExistingRegistrationsCompatibility.isIncompatible()) {
            return TypeSerializerSchemaCompatibility.incompatible();
        }

        if (newPojoSerializerIsCompatibleAfterMigration(
                preExistingFieldSerializersCompatibility,
                preExistingRegistrationsCompatibility,
                fieldSerializerSnapshots)) {

            return TypeSerializerSchemaCompatibility.compatibleAfterMigration();
        }

        if (newPojoSerializerIsCompatibleWithReconfiguredSerializer(
                preExistingFieldSerializersCompatibility,
                preExistingRegistrationsCompatibility,
                registeredSubclassSerializerSnapshots,
                nonRegisteredSubclassSerializerSnapshots)) {

            return TypeSerializerSchemaCompatibility.compatibleWithReconfiguredSerializer(
                    constructReconfiguredPojoSerializer(
                            preExistingFieldSerializersCompatibility,
                            registeredSubclassSerializerSnapshots,
                            preExistingRegistrationsCompatibility,
                            nonRegisteredSubclassSerializerSnapshots));
        }

        return TypeSerializerSchemaCompatibility.compatibleAsIs();
    }
@Test
    void testResolveSchemaCompatibilityWithCompatibleWithReconfigurationFieldSerializers() {
        final PojoSerializerSnapshot<TestPojo> oldSnapshot =
                buildTestSnapshot(
                        Arrays.asList(
                                mockFieldSerializerSnapshot(
                                        ID_FIELD,
                                        new SchemaCompatibilityTestingSerializer()
                                                .snapshotConfiguration()),
                                NAME_FIELD,
                                HEIGHT_FIELD));

        final PojoSerializerSnapshot<TestPojo> newSnapshot =
                buildTestSnapshot(
                        Arrays.asList(
                                mockFieldSerializerSnapshot(
                                        ID_FIELD,
                                        SchemaCompatibilityTestingSnapshot
                                                .thatIsCompatibleWithLastSerializerAfterReconfiguration()),
                                NAME_FIELD,
                                HEIGHT_FIELD));

        final TypeSerializerSchemaCompatibility<TestPojo> resultCompatibility =
                newSnapshot.resolveSchemaCompatibility(oldSnapshot);

        assertThat(resultCompatibility.isCompatibleWithReconfiguredSerializer()).isTrue();

        final TypeSerializer<TestPojo> reconfiguredSerializer =
                resultCompatibility.getReconfiguredSerializer();
        assertThat(reconfiguredSerializer.getClass()).isSameAs(PojoSerializer.class);
        final PojoSerializer<TestPojo> reconfiguredPojoSerializer =
                (PojoSerializer<TestPojo>) reconfiguredSerializer;

        final TypeSerializer<?>[] reconfiguredFieldSerializers =
                reconfiguredPojoSerializer.getFieldSerializers();
        assertThat(reconfiguredFieldSerializers)
                .containsExactly(
                        new SchemaCompatibilityTestingSerializer(),
                        StringSerializer.INSTANCE,
                        DoubleSerializer.INSTANCE);
    }