/**
  * Checks compatibility of changes according to
  * http://docs.oracle.com/javase/7/docs/platform/serialization/spec/version.html#5172.
  *
  * @param jApiClass the class to check
  * @return either SERIALIZABLE_INCOMPATIBLE or SERIALIZABLE_COMPATIBLE
  */
 private JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
     checkChanges(JApiClass jApiClass) {
   JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus state =
       JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
           .SERIALIZABLE_COMPATIBLE;
   if (jApiClass.getChangeStatus() == JApiChangeStatus.REMOVED) {
     return JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
         .SERIALIZABLE_INCOMPATIBLE_CLASS_REMOVED;
   }
   state = checkChangesForClassType(jApiClass, state);
   if (state
       != JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
           .SERIALIZABLE_COMPATIBLE) {
     return state;
   }
   state = checkChangesForSuperclass(jApiClass, state);
   if (state
       != JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
           .SERIALIZABLE_COMPATIBLE) {
     return state;
   }
   state = checkChangesForFields(jApiClass, state);
   if (state
       != JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
           .SERIALIZABLE_COMPATIBLE) {
     return state;
   }
   state = checkChangesForInterfaces(jApiClass, state);
   return state;
 }
 private void computeChangeStatus(JApiClass jApiClass) {
   JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus state =
       JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
           .NOT_SERIALIZABLE;
   JApiSerialVersionUid jApiSerialVersionUid = jApiClass.getSerialVersionUid();
   if (jApiSerialVersionUid.isSerializableOld() || jApiSerialVersionUid.isSerializableNew()) {
     state = checkChanges(jApiClass);
     if (!state.isIncompatible()) {
       if (jApiSerialVersionUid.getSerialVersionUidInClassOld().isPresent()
           && jApiSerialVersionUid.getSerialVersionUidInClassNew().isPresent()) {
         Long suidOld = jApiSerialVersionUid.getSerialVersionUidInClassOld().get();
         Long suidNew = jApiSerialVersionUid.getSerialVersionUidInClassNew().get();
         if (suidOld.equals(suidNew)) {
           state =
               JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
                   .SERIALIZABLE_COMPATIBLE;
         } else {
           state =
               JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
                   .SERIALIZABLE_INCOMPATIBLE_SERIALVERSIONUID_MODIFIED;
         }
       } else if (jApiSerialVersionUid.getSerialVersionUidInClassOld().isPresent()) {
         if (jApiClass.getChangeStatus() != JApiChangeStatus.REMOVED) {
           if (jApiSerialVersionUid.isSerializableNew()) {
             Long suidOld = jApiSerialVersionUid.getSerialVersionUidInClassOld().get();
             if (jApiSerialVersionUid.getSerialVersionUidDefaultNew().isPresent()) {
               Long suidNewDefault = jApiSerialVersionUid.getSerialVersionUidDefaultNew().get();
               if (suidOld.equals(suidNewDefault)) {
                 state =
                     JApiJavaObjectSerializationCompatibility
                         .JApiJavaObjectSerializationChangeStatus.SERIALIZABLE_COMPATIBLE;
               } else {
                 state =
                     JApiJavaObjectSerializationCompatibility
                         .JApiJavaObjectSerializationChangeStatus
                         .SERIALIZABLE_INCOMPATIBLE_SERIALVERSIONUID_REMOVED_AND_NOT_MACHTES_NEW_DEFAULT;
               }
             } else {
               state =
                   JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
                       .SERIALIZABLE_INCOMPATIBLE_CLASS_REMOVED;
             }
           } else {
             state =
                 JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
                     .SERIALIZABLE_INCOMPATIBLE_SERIALIZABLE_REMOVED;
           }
         } else {
           state =
               JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
                   .SERIALIZABLE_INCOMPATIBLE_CLASS_REMOVED;
         }
       } else if (jApiSerialVersionUid.getSerialVersionUidInClassNew().isPresent()) {
         if (jApiClass.getChangeStatus() != JApiChangeStatus.NEW) {
           if (jApiSerialVersionUid.isSerializableOld()) {
             Long suidNew = jApiSerialVersionUid.getSerialVersionUidInClassNew().get();
             if (jApiSerialVersionUid.getSerialVersionUidDefaultOld().isPresent()) {
               Long suidOldDefault = jApiSerialVersionUid.getSerialVersionUidDefaultOld().get();
               if (suidNew.equals(suidOldDefault)) {
                 state =
                     JApiJavaObjectSerializationCompatibility
                         .JApiJavaObjectSerializationChangeStatus.SERIALIZABLE_COMPATIBLE;
               } else {
                 state =
                     JApiJavaObjectSerializationCompatibility
                         .JApiJavaObjectSerializationChangeStatus
                         .SERIALIZABLE_INCOMPATIBLE_SERIALVERSIONUID_REMOVED_AND_NOT_MACHTES_NEW_DEFAULT;
               }
             } else {
               state =
                   JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
                       .SERIALIZABLE_COMPATIBLE;
             }
           }
         } else {
           state =
               JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
                   .SERIALIZABLE_COMPATIBLE;
         }
       } else {
         if (jApiClass.getChangeStatus() == JApiChangeStatus.NEW) {
           state =
               JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
                   .SERIALIZABLE_COMPATIBLE;
         } else if (jApiClass.getChangeStatus() == JApiChangeStatus.REMOVED) {
           state =
               JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
                   .SERIALIZABLE_INCOMPATIBLE_CLASS_REMOVED;
         } else {
           if (jApiSerialVersionUid.getSerialVersionUidDefaultOld().isPresent()
               && jApiSerialVersionUid.getSerialVersionUidDefaultNew().isPresent()) {
             Long defaultOld = jApiSerialVersionUid.getSerialVersionUidDefaultOld().get();
             Long defaultNew = jApiSerialVersionUid.getSerialVersionUidDefaultNew().get();
             if (defaultOld.equals(defaultNew)) {
               state =
                   JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
                       .SERIALIZABLE_COMPATIBLE;
             } else {
               state =
                   JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
                       .SERIALIZABLE_INCOMPATIBLE_DEFAULT_SERIALVERSIONUID_CHANGED;
             }
           } else if (jApiSerialVersionUid.getSerialVersionUidDefaultOld().isPresent()) {
             state =
                 JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
                     .SERIALIZABLE_INCOMPATIBLE_SERIALIZABLE_REMOVED;
           } else {
             state =
                 JApiJavaObjectSerializationCompatibility.JApiJavaObjectSerializationChangeStatus
                     .SERIALIZABLE_COMPATIBLE;
           }
         }
       }
     }
   }
   jApiClass.setJavaObjectSerializationCompatible(state);
 }