Buggy code:
public class Church extends Location implements Cloneable { public static final long INVALID_ID = - 1 ; private static final int DEVELOPMENT_UNKNOWN = 0 ; private static final int DEVELOPMENT_TARGET = 1 ; private static final int DEVELOPMENT_GROUP = 2 ; private static final int DEVELOPMENT_CHURCH = 3 ; private static final int DEVELOPMENT_MULTIPLYING_CHURCH = 5 ; public enum Development { UNKNOWN ( Church . DEVELOPMENT_UNKNOWN ) , TARGET ( Church . DEVELOPMENT_TARGET ) , GROUP ( Church . DEVELOPMENT_GROUP ) , CHURCH ( Church . DEVELOPMENT_CHURCH ) , MULTIPLYING_CHURCH ( Church . DEVELOPMENT_MULTIPLYING_CHURCH ) ; public final int id ; private Development ( final int id ) { } @ NonNull public static Church . Development fromRaw ( final int index ) { } } private static final int SECURITY_LOCAL_PRIVATE = 0 ; private static final int SECURITY_PRIVATE = 1 ; private static final int SECURITY_PUBLIC = 2 ; public static final int SECURITY_DEFAULT = Church . SECURITY_PUBLIC ; public enum Security { LOCAL_PRIVATE ( Church . SECURITY_LOCAL_PRIVATE ) , PRIVATE ( Church . SECURITY_PRIVATE ) , PUBLIC ( Church . SECURITY_PUBLIC ) ; public final int id ; private Security ( final int id ) { } @ NonNull public static Church . Security fromRaw ( final int id ) { } } public static final String JSON_ID = "id" ; public static final String JSON_MINISTRY_ID = "ministry_id" ; public static final String JSON_NAME = "name" ; public static final String JSON_CONTACT_EMAIL = "contact_email" ; public static final String JSON_CONTACT_NAME = "contact_name" ; public static final String JSON_LATITUDE = "latitude" ; public static final String JSON_LONGITUDE = "longitude" ; public static final String JSON_DEVELOPMENT = "development" ; public static final String JSON_SIZE = "size" ; public static final String JSON_SECURITY = "security" ; private long id = Church . INVALID_ID ; @ NonNull private String ministryId = Ministry . INVALID_ID ; @ Nullable private String name ; @ Nullable private String contactEmail ; @ Nullable private String contactName ; @ NonNull private Church . Development development = Church . Development . UNKNOWN ; @ NonNull private Church . Security security = Church . Security . PUBLIC ; private int size = 0 ; private boolean mNew = false ; @ NonNull private final Set < String > mDirty = new HashSet < > ( ) ; private boolean mTrackingChanges = false ; @ NonNull public static List < Church > listFromJson ( @ NonNull final JSONArray json ) throws JSONException { } @ NonNull public static Church fromJson ( @ NonNull final JSONObject json ) throws JSONException { } public Church ( ) { } private Church ( @ NonNull final Church church ) { } public long getId ( ) { } public void setId ( final long id ) { } @ NonNull public String getMinistryId ( ) { } public void setMinistryId ( @ NonNull final String ministryId ) { } @ Nullable public String getName ( ) { } public void setName ( @ Nullable final String name ) { } @ Nullable public String getContactEmail ( ) { } public void setContactEmail ( @ Nullable final String email ) { } @ Nullable public String getContactName ( ) { } public void setContactName ( @ Nullable final String name ) { } @ NonNull public Church . Development getDevelopment ( ) { } public void setDevelopment ( @ NonNull final Church . Development development ) { } public int getSize ( ) { } public void setSize ( final int size ) { } @ NonNull public Church . Security getSecurity ( ) { } public void setSecurity ( @ NonNull final Church . Security security ) { } public void setNew ( final boolean state ) { } public boolean isNew ( ) { } public void setDirty ( @ Nullable final String dirty ) { } @ NonNull public String getDirty ( ) { } public boolean isDirty ( ) { } public void trackingChanges ( final boolean state ) { } @ Override public Church clone ( ) { } public JSONObject dirtyToJson ( ) throws JSONException { } public JSONObject toJson ( ) throws JSONException { final JSONObject json = new JSONObject ( ) ; json . put ( Church . JSON_MINISTRY_ID , this . ministryId ) ; json . put ( Church . JSON_NAME , this . name ) ; json . put ( Church . JSON_CONTACT_NAME , this . contactName ) ; json . put ( Church . JSON_CONTACT_EMAIL , this . contactEmail ) ; json . put ( Church . JSON_LATITUDE , this . getLatitude ( ) ) ; json . put ( Church . JSON_LONGITUDE , this . getLongitude ( ) ) ; if ( ( this . development ) != ( Church . Development . UNKNOWN ) ) { json . put ( Church . JSON_DEVELOPMENT , this . development . id ) ; } json . put ( Church . JSON_SIZE , this . size ) ; <START_BUG> json . put ( Church . JSON_SECURITY , this . security ) ; <END_BUG> return json ; } }

Fix:
json . put ( Church . JSON_SECURITY , this . security . id ) ;