package io.realm;


import android.util.JsonReader;
import android.util.JsonToken;
import com.mgdiez.data.bean.vo.tweet.TweetVo;
import io.realm.RealmFieldType;
import io.realm.exceptions.RealmMigrationNeededException;
import io.realm.internal.ColumnInfo;
import io.realm.internal.ImplicitTransaction;
import io.realm.internal.LinkView;
import io.realm.internal.RealmObjectProxy;
import io.realm.internal.Table;
import io.realm.internal.TableOrView;
import io.realm.internal.android.JsonUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class TweetVoRealmProxy extends TweetVo
    implements RealmObjectProxy {

    static final class TweetVoColumnInfo extends ColumnInfo {

        public final long idIndex;
        public final long titleIndex;
        public final long descriptionIndex;
        public final long thumbnailUrlIndex;
        public final long userNameIndex;
        public final long createdAtIndex;
        public final long cityIndex;
        public final long countryIndex;
        public final long locationIndex;
        public final long latitudeIndex;
        public final long longitudeIndex;
        public final long queryIndex;

        TweetVoColumnInfo(String path, Table table) {
            final Map<String, Long> indicesMap = new HashMap<String, Long>(12);
            this.idIndex = getValidColumnIndex(path, table, "TweetVo", "id");
            indicesMap.put("id", this.idIndex);

            this.titleIndex = getValidColumnIndex(path, table, "TweetVo", "title");
            indicesMap.put("title", this.titleIndex);

            this.descriptionIndex = getValidColumnIndex(path, table, "TweetVo", "description");
            indicesMap.put("description", this.descriptionIndex);

            this.thumbnailUrlIndex = getValidColumnIndex(path, table, "TweetVo", "thumbnailUrl");
            indicesMap.put("thumbnailUrl", this.thumbnailUrlIndex);

            this.userNameIndex = getValidColumnIndex(path, table, "TweetVo", "userName");
            indicesMap.put("userName", this.userNameIndex);

            this.createdAtIndex = getValidColumnIndex(path, table, "TweetVo", "createdAt");
            indicesMap.put("createdAt", this.createdAtIndex);

            this.cityIndex = getValidColumnIndex(path, table, "TweetVo", "city");
            indicesMap.put("city", this.cityIndex);

            this.countryIndex = getValidColumnIndex(path, table, "TweetVo", "country");
            indicesMap.put("country", this.countryIndex);

            this.locationIndex = getValidColumnIndex(path, table, "TweetVo", "location");
            indicesMap.put("location", this.locationIndex);

            this.latitudeIndex = getValidColumnIndex(path, table, "TweetVo", "latitude");
            indicesMap.put("latitude", this.latitudeIndex);

            this.longitudeIndex = getValidColumnIndex(path, table, "TweetVo", "longitude");
            indicesMap.put("longitude", this.longitudeIndex);

            this.queryIndex = getValidColumnIndex(path, table, "TweetVo", "query");
            indicesMap.put("query", this.queryIndex);

            setIndicesMap(indicesMap);
        }
    }

    private final TweetVoColumnInfo columnInfo;
    private static final List<String> FIELD_NAMES;
    static {
        List<String> fieldNames = new ArrayList<String>();
        fieldNames.add("id");
        fieldNames.add("title");
        fieldNames.add("description");
        fieldNames.add("thumbnailUrl");
        fieldNames.add("userName");
        fieldNames.add("createdAt");
        fieldNames.add("city");
        fieldNames.add("country");
        fieldNames.add("location");
        fieldNames.add("latitude");
        fieldNames.add("longitude");
        fieldNames.add("query");
        FIELD_NAMES = Collections.unmodifiableList(fieldNames);
    }

    TweetVoRealmProxy(ColumnInfo columnInfo) {
        this.columnInfo = (TweetVoColumnInfo) columnInfo;
    }

    @Override
    @SuppressWarnings("cast")
    public long getId() {
        realm.checkIfValid();
        return (long) row.getLong(columnInfo.idIndex);
    }

    @Override
    public void setId(long value) {
        realm.checkIfValid();
        row.setLong(columnInfo.idIndex, value);
    }

    @Override
    @SuppressWarnings("cast")
    public String getTitle() {
        realm.checkIfValid();
        return (java.lang.String) row.getString(columnInfo.titleIndex);
    }

    @Override
    public void setTitle(String value) {
        realm.checkIfValid();
        if (value == null) {
            row.setNull(columnInfo.titleIndex);
            return;
        }
        row.setString(columnInfo.titleIndex, value);
    }

    @Override
    @SuppressWarnings("cast")
    public String getDescription() {
        realm.checkIfValid();
        return (java.lang.String) row.getString(columnInfo.descriptionIndex);
    }

    @Override
    public void setDescription(String value) {
        realm.checkIfValid();
        if (value == null) {
            row.setNull(columnInfo.descriptionIndex);
            return;
        }
        row.setString(columnInfo.descriptionIndex, value);
    }

    @Override
    @SuppressWarnings("cast")
    public String getThumbnailUrl() {
        realm.checkIfValid();
        return (java.lang.String) row.getString(columnInfo.thumbnailUrlIndex);
    }

    @Override
    public void setThumbnailUrl(String value) {
        realm.checkIfValid();
        if (value == null) {
            row.setNull(columnInfo.thumbnailUrlIndex);
            return;
        }
        row.setString(columnInfo.thumbnailUrlIndex, value);
    }

    @Override
    @SuppressWarnings("cast")
    public String getUserName() {
        realm.checkIfValid();
        return (java.lang.String) row.getString(columnInfo.userNameIndex);
    }

    @Override
    public void setUserName(String value) {
        realm.checkIfValid();
        if (value == null) {
            row.setNull(columnInfo.userNameIndex);
            return;
        }
        row.setString(columnInfo.userNameIndex, value);
    }

    @Override
    @SuppressWarnings("cast")
    public String getCreatedAt() {
        realm.checkIfValid();
        return (java.lang.String) row.getString(columnInfo.createdAtIndex);
    }

    @Override
    public void setCreatedAt(String value) {
        realm.checkIfValid();
        if (value == null) {
            row.setNull(columnInfo.createdAtIndex);
            return;
        }
        row.setString(columnInfo.createdAtIndex, value);
    }

    @Override
    @SuppressWarnings("cast")
    public String getCity() {
        realm.checkIfValid();
        return (java.lang.String) row.getString(columnInfo.cityIndex);
    }

    @Override
    public void setCity(String value) {
        realm.checkIfValid();
        if (value == null) {
            row.setNull(columnInfo.cityIndex);
            return;
        }
        row.setString(columnInfo.cityIndex, value);
    }

    @Override
    @SuppressWarnings("cast")
    public String getCountry() {
        realm.checkIfValid();
        return (java.lang.String) row.getString(columnInfo.countryIndex);
    }

    @Override
    public void setCountry(String value) {
        realm.checkIfValid();
        if (value == null) {
            row.setNull(columnInfo.countryIndex);
            return;
        }
        row.setString(columnInfo.countryIndex, value);
    }

    @Override
    @SuppressWarnings("cast")
    public String getLocation() {
        realm.checkIfValid();
        return (java.lang.String) row.getString(columnInfo.locationIndex);
    }

    @Override
    public void setLocation(String value) {
        realm.checkIfValid();
        if (value == null) {
            row.setNull(columnInfo.locationIndex);
            return;
        }
        row.setString(columnInfo.locationIndex, value);
    }

    @Override
    @SuppressWarnings("cast")
    public Double getLatitude() {
        realm.checkIfValid();
        if (row.isNull(columnInfo.latitudeIndex)) {
            return null;
        }
        return (double) row.getDouble(columnInfo.latitudeIndex);
    }

    @Override
    public void setLatitude(Double value) {
        realm.checkIfValid();
        if (value == null) {
            row.setNull(columnInfo.latitudeIndex);
            return;
        }
        row.setDouble(columnInfo.latitudeIndex, value);
    }

    @Override
    @SuppressWarnings("cast")
    public Double getLongitude() {
        realm.checkIfValid();
        if (row.isNull(columnInfo.longitudeIndex)) {
            return null;
        }
        return (double) row.getDouble(columnInfo.longitudeIndex);
    }

    @Override
    public void setLongitude(Double value) {
        realm.checkIfValid();
        if (value == null) {
            row.setNull(columnInfo.longitudeIndex);
            return;
        }
        row.setDouble(columnInfo.longitudeIndex, value);
    }

    @Override
    @SuppressWarnings("cast")
    public String getQuery() {
        realm.checkIfValid();
        return (java.lang.String) row.getString(columnInfo.queryIndex);
    }

    @Override
    public void setQuery(String value) {
        realm.checkIfValid();
        if (value == null) {
            row.setNull(columnInfo.queryIndex);
            return;
        }
        row.setString(columnInfo.queryIndex, value);
    }

    public static Table initTable(ImplicitTransaction transaction) {
        if (!transaction.hasTable("class_TweetVo")) {
            Table table = transaction.getTable("class_TweetVo");
            table.addColumn(RealmFieldType.INTEGER, "id", Table.NOT_NULLABLE);
            table.addColumn(RealmFieldType.STRING, "title", Table.NULLABLE);
            table.addColumn(RealmFieldType.STRING, "description", Table.NULLABLE);
            table.addColumn(RealmFieldType.STRING, "thumbnailUrl", Table.NULLABLE);
            table.addColumn(RealmFieldType.STRING, "userName", Table.NULLABLE);
            table.addColumn(RealmFieldType.STRING, "createdAt", Table.NULLABLE);
            table.addColumn(RealmFieldType.STRING, "city", Table.NULLABLE);
            table.addColumn(RealmFieldType.STRING, "country", Table.NULLABLE);
            table.addColumn(RealmFieldType.STRING, "location", Table.NULLABLE);
            table.addColumn(RealmFieldType.DOUBLE, "latitude", Table.NULLABLE);
            table.addColumn(RealmFieldType.DOUBLE, "longitude", Table.NULLABLE);
            table.addColumn(RealmFieldType.STRING, "query", Table.NULLABLE);
            table.addSearchIndex(table.getColumnIndex("id"));
            table.setPrimaryKey("id");
            return table;
        }
        return transaction.getTable("class_TweetVo");
    }

    public static TweetVoColumnInfo validateTable(ImplicitTransaction transaction) {
        if (transaction.hasTable("class_TweetVo")) {
            Table table = transaction.getTable("class_TweetVo");
            if (table.getColumnCount() != 12) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field count does not match - expected 12 but was " + table.getColumnCount());
            }
            Map<String, RealmFieldType> columnTypes = new HashMap<String, RealmFieldType>();
            for (long i = 0; i < 12; i++) {
                columnTypes.put(table.getColumnName(i), table.getColumnType(i));
            }

            final TweetVoColumnInfo columnInfo = new TweetVoColumnInfo(transaction.getPath(), table);

            if (!columnTypes.containsKey("id")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'id' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("id") != RealmFieldType.INTEGER) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'long' for field 'id' in existing Realm file.");
            }
            if (table.isColumnNullable(columnInfo.idIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field 'id' does support null values in the existing Realm file. Use corresponding boxed type for field 'id' or migrate using io.realm.internal.Table.convertColumnToNotNullable().");
            }
            if (table.getPrimaryKey() != table.getColumnIndex("id")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Primary key not defined for field 'id' in existing Realm file. Add @PrimaryKey.");
            }
            if (!table.hasSearchIndex(table.getColumnIndex("id"))) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Index not defined for field 'id' in existing Realm file. Either set @Index or migrate using io.realm.internal.Table.removeSearchIndex().");
            }
            if (!columnTypes.containsKey("title")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'title' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("title") != RealmFieldType.STRING) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'String' for field 'title' in existing Realm file.");
            }
            if (!table.isColumnNullable(columnInfo.titleIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field 'title' is required. Either set @Required to field 'title' or migrate using io.realm.internal.Table.convertColumnToNullable().");
            }
            if (!columnTypes.containsKey("description")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'description' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("description") != RealmFieldType.STRING) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'String' for field 'description' in existing Realm file.");
            }
            if (!table.isColumnNullable(columnInfo.descriptionIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field 'description' is required. Either set @Required to field 'description' or migrate using io.realm.internal.Table.convertColumnToNullable().");
            }
            if (!columnTypes.containsKey("thumbnailUrl")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'thumbnailUrl' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("thumbnailUrl") != RealmFieldType.STRING) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'String' for field 'thumbnailUrl' in existing Realm file.");
            }
            if (!table.isColumnNullable(columnInfo.thumbnailUrlIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field 'thumbnailUrl' is required. Either set @Required to field 'thumbnailUrl' or migrate using io.realm.internal.Table.convertColumnToNullable().");
            }
            if (!columnTypes.containsKey("userName")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'userName' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("userName") != RealmFieldType.STRING) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'String' for field 'userName' in existing Realm file.");
            }
            if (!table.isColumnNullable(columnInfo.userNameIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field 'userName' is required. Either set @Required to field 'userName' or migrate using io.realm.internal.Table.convertColumnToNullable().");
            }
            if (!columnTypes.containsKey("createdAt")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'createdAt' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("createdAt") != RealmFieldType.STRING) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'String' for field 'createdAt' in existing Realm file.");
            }
            if (!table.isColumnNullable(columnInfo.createdAtIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field 'createdAt' is required. Either set @Required to field 'createdAt' or migrate using io.realm.internal.Table.convertColumnToNullable().");
            }
            if (!columnTypes.containsKey("city")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'city' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("city") != RealmFieldType.STRING) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'String' for field 'city' in existing Realm file.");
            }
            if (!table.isColumnNullable(columnInfo.cityIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field 'city' is required. Either set @Required to field 'city' or migrate using io.realm.internal.Table.convertColumnToNullable().");
            }
            if (!columnTypes.containsKey("country")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'country' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("country") != RealmFieldType.STRING) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'String' for field 'country' in existing Realm file.");
            }
            if (!table.isColumnNullable(columnInfo.countryIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field 'country' is required. Either set @Required to field 'country' or migrate using io.realm.internal.Table.convertColumnToNullable().");
            }
            if (!columnTypes.containsKey("location")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'location' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("location") != RealmFieldType.STRING) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'String' for field 'location' in existing Realm file.");
            }
            if (!table.isColumnNullable(columnInfo.locationIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field 'location' is required. Either set @Required to field 'location' or migrate using io.realm.internal.Table.convertColumnToNullable().");
            }
            if (!columnTypes.containsKey("latitude")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'latitude' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("latitude") != RealmFieldType.DOUBLE) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'Double' for field 'latitude' in existing Realm file.");
            }
            if (!table.isColumnNullable(columnInfo.latitudeIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(),"Field 'latitude' does not support null values in the existing Realm file. Either set @Required, use the primitive type for field 'latitude' or migrate using io.realm.internal.Table.convertColumnToNullable().");
            }
            if (!columnTypes.containsKey("longitude")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'longitude' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("longitude") != RealmFieldType.DOUBLE) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'Double' for field 'longitude' in existing Realm file.");
            }
            if (!table.isColumnNullable(columnInfo.longitudeIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(),"Field 'longitude' does not support null values in the existing Realm file. Either set @Required, use the primitive type for field 'longitude' or migrate using io.realm.internal.Table.convertColumnToNullable().");
            }
            if (!columnTypes.containsKey("query")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'query' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("query") != RealmFieldType.STRING) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'String' for field 'query' in existing Realm file.");
            }
            if (!table.isColumnNullable(columnInfo.queryIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field 'query' is required. Either set @Required to field 'query' or migrate using io.realm.internal.Table.convertColumnToNullable().");
            }
            return columnInfo;
        } else {
            throw new RealmMigrationNeededException(transaction.getPath(), "The TweetVo class is missing from the schema for this Realm.");
        }
    }

    public static String getTableName() {
        return "class_TweetVo";
    }

    public static List<String> getFieldNames() {
        return FIELD_NAMES;
    }

    @SuppressWarnings("cast")
    public static TweetVo createOrUpdateUsingJsonObject(Realm realm, JSONObject json, boolean update)
        throws JSONException {
        TweetVo obj = null;
        if (update) {
            Table table = realm.getTable(TweetVo.class);
            long pkColumnIndex = table.getPrimaryKey();
            if (!json.isNull("id")) {
                long rowIndex = table.findFirstLong(pkColumnIndex, json.getLong("id"));
                if (rowIndex != TableOrView.NO_MATCH) {
                    obj = new TweetVoRealmProxy(realm.schema.getColumnInfo(TweetVo.class));
                    obj.realm = realm;
                    obj.row = table.getUncheckedRow(rowIndex);
                }
            }
        }
        if (obj == null) {
            if (json.has("id")) {
                if (json.isNull("id")) {
                    obj = realm.createObject(TweetVo.class, null);
                } else {
                    obj = realm.createObject(TweetVo.class, json.getLong("id"));
                }
            } else {
                obj = realm.createObject(TweetVo.class);
            }
        }
        if (json.has("id")) {
            if (json.isNull("id")) {
                throw new IllegalArgumentException("Trying to set non-nullable field id to null.");
            } else {
                obj.setId((long) json.getLong("id"));
            }
        }
        if (json.has("title")) {
            if (json.isNull("title")) {
                obj.setTitle(null);
            } else {
                obj.setTitle((String) json.getString("title"));
            }
        }
        if (json.has("description")) {
            if (json.isNull("description")) {
                obj.setDescription(null);
            } else {
                obj.setDescription((String) json.getString("description"));
            }
        }
        if (json.has("thumbnailUrl")) {
            if (json.isNull("thumbnailUrl")) {
                obj.setThumbnailUrl(null);
            } else {
                obj.setThumbnailUrl((String) json.getString("thumbnailUrl"));
            }
        }
        if (json.has("userName")) {
            if (json.isNull("userName")) {
                obj.setUserName(null);
            } else {
                obj.setUserName((String) json.getString("userName"));
            }
        }
        if (json.has("createdAt")) {
            if (json.isNull("createdAt")) {
                obj.setCreatedAt(null);
            } else {
                obj.setCreatedAt((String) json.getString("createdAt"));
            }
        }
        if (json.has("city")) {
            if (json.isNull("city")) {
                obj.setCity(null);
            } else {
                obj.setCity((String) json.getString("city"));
            }
        }
        if (json.has("country")) {
            if (json.isNull("country")) {
                obj.setCountry(null);
            } else {
                obj.setCountry((String) json.getString("country"));
            }
        }
        if (json.has("location")) {
            if (json.isNull("location")) {
                obj.setLocation(null);
            } else {
                obj.setLocation((String) json.getString("location"));
            }
        }
        if (json.has("latitude")) {
            if (json.isNull("latitude")) {
                obj.setLatitude(null);
            } else {
                obj.setLatitude((double) json.getDouble("latitude"));
            }
        }
        if (json.has("longitude")) {
            if (json.isNull("longitude")) {
                obj.setLongitude(null);
            } else {
                obj.setLongitude((double) json.getDouble("longitude"));
            }
        }
        if (json.has("query")) {
            if (json.isNull("query")) {
                obj.setQuery(null);
            } else {
                obj.setQuery((String) json.getString("query"));
            }
        }
        return obj;
    }

    @SuppressWarnings("cast")
    public static TweetVo createUsingJsonStream(Realm realm, JsonReader reader)
        throws IOException {
        TweetVo obj = realm.createObject(TweetVo.class);
        reader.beginObject();
        while (reader.hasNext()) {
            String name = reader.nextName();
            if (name.equals("id")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    throw new IllegalArgumentException("Trying to set non-nullable field id to null.");
                } else {
                    obj.setId((long) reader.nextLong());
                }
            } else if (name.equals("title")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setTitle(null);
                } else {
                    obj.setTitle((String) reader.nextString());
                }
            } else if (name.equals("description")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setDescription(null);
                } else {
                    obj.setDescription((String) reader.nextString());
                }
            } else if (name.equals("thumbnailUrl")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setThumbnailUrl(null);
                } else {
                    obj.setThumbnailUrl((String) reader.nextString());
                }
            } else if (name.equals("userName")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setUserName(null);
                } else {
                    obj.setUserName((String) reader.nextString());
                }
            } else if (name.equals("createdAt")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setCreatedAt(null);
                } else {
                    obj.setCreatedAt((String) reader.nextString());
                }
            } else if (name.equals("city")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setCity(null);
                } else {
                    obj.setCity((String) reader.nextString());
                }
            } else if (name.equals("country")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setCountry(null);
                } else {
                    obj.setCountry((String) reader.nextString());
                }
            } else if (name.equals("location")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setLocation(null);
                } else {
                    obj.setLocation((String) reader.nextString());
                }
            } else if (name.equals("latitude")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setLatitude(null);
                } else {
                    obj.setLatitude((double) reader.nextDouble());
                }
            } else if (name.equals("longitude")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setLongitude(null);
                } else {
                    obj.setLongitude((double) reader.nextDouble());
                }
            } else if (name.equals("query")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setQuery(null);
                } else {
                    obj.setQuery((String) reader.nextString());
                }
            } else {
                reader.skipValue();
            }
        }
        reader.endObject();
        return obj;
    }

    public static TweetVo copyOrUpdate(Realm realm, TweetVo object, boolean update, Map<RealmObject,RealmObjectProxy> cache) {
        if (object.realm != null && object.realm.getPath().equals(realm.getPath())) {
            return object;
        }
        TweetVo realmObject = null;
        boolean canUpdate = update;
        if (canUpdate) {
            Table table = realm.getTable(TweetVo.class);
            long pkColumnIndex = table.getPrimaryKey();
            long rowIndex = table.findFirstLong(pkColumnIndex, object.getId());
            if (rowIndex != TableOrView.NO_MATCH) {
                realmObject = new TweetVoRealmProxy(realm.schema.getColumnInfo(TweetVo.class));
                realmObject.realm = realm;
                realmObject.row = table.getUncheckedRow(rowIndex);
                cache.put(object, (RealmObjectProxy) realmObject);
            } else {
                canUpdate = false;
            }
        }

        if (canUpdate) {
            return update(realm, realmObject, object, cache);
        } else {
            return copy(realm, object, update, cache);
        }
    }

    public static TweetVo copy(Realm realm, TweetVo newObject, boolean update, Map<RealmObject,RealmObjectProxy> cache) {
        TweetVo realmObject = realm.createObject(TweetVo.class, newObject.getId());
        cache.put(newObject, (RealmObjectProxy) realmObject);
        realmObject.setId(newObject.getId());
        realmObject.setTitle(newObject.getTitle());
        realmObject.setDescription(newObject.getDescription());
        realmObject.setThumbnailUrl(newObject.getThumbnailUrl());
        realmObject.setUserName(newObject.getUserName());
        realmObject.setCreatedAt(newObject.getCreatedAt());
        realmObject.setCity(newObject.getCity());
        realmObject.setCountry(newObject.getCountry());
        realmObject.setLocation(newObject.getLocation());
        realmObject.setLatitude(newObject.getLatitude());
        realmObject.setLongitude(newObject.getLongitude());
        realmObject.setQuery(newObject.getQuery());
        return realmObject;
    }

    public static TweetVo createDetachedCopy(TweetVo realmObject, int currentDepth, int maxDepth, Map<RealmObject, CacheData<RealmObject>> cache) {
        if (currentDepth > maxDepth || realmObject == null) {
            return null;
        }
        CacheData<TweetVo> cachedObject = (CacheData) cache.get(realmObject);
        TweetVo standaloneObject;
        if (cachedObject != null) {
            // Reuse cached object or recreate it because it was encountered at a lower depth.
            if (currentDepth >= cachedObject.minDepth) {
                return cachedObject.object;
            } else {
                standaloneObject = cachedObject.object;
                cachedObject.minDepth = currentDepth;
            }
        } else {
            standaloneObject = new TweetVo();
            cache.put(realmObject, new RealmObjectProxy.CacheData<RealmObject>(currentDepth, standaloneObject));
        }
        standaloneObject.setId(realmObject.getId());
        standaloneObject.setTitle(realmObject.getTitle());
        standaloneObject.setDescription(realmObject.getDescription());
        standaloneObject.setThumbnailUrl(realmObject.getThumbnailUrl());
        standaloneObject.setUserName(realmObject.getUserName());
        standaloneObject.setCreatedAt(realmObject.getCreatedAt());
        standaloneObject.setCity(realmObject.getCity());
        standaloneObject.setCountry(realmObject.getCountry());
        standaloneObject.setLocation(realmObject.getLocation());
        standaloneObject.setLatitude(realmObject.getLatitude());
        standaloneObject.setLongitude(realmObject.getLongitude());
        standaloneObject.setQuery(realmObject.getQuery());
        return standaloneObject;
    }

    static TweetVo update(Realm realm, TweetVo realmObject, TweetVo newObject, Map<RealmObject, RealmObjectProxy> cache) {
        realmObject.setTitle(newObject.getTitle());
        realmObject.setDescription(newObject.getDescription());
        realmObject.setThumbnailUrl(newObject.getThumbnailUrl());
        realmObject.setUserName(newObject.getUserName());
        realmObject.setCreatedAt(newObject.getCreatedAt());
        realmObject.setCity(newObject.getCity());
        realmObject.setCountry(newObject.getCountry());
        realmObject.setLocation(newObject.getLocation());
        realmObject.setLatitude(newObject.getLatitude());
        realmObject.setLongitude(newObject.getLongitude());
        realmObject.setQuery(newObject.getQuery());
        return realmObject;
    }

    @Override
    public String toString() {
        if (!isValid()) {
            return "Invalid object";
        }
        StringBuilder stringBuilder = new StringBuilder("TweetVo = [");
        stringBuilder.append("{id:");
        stringBuilder.append(getId());
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{title:");
        stringBuilder.append(getTitle() != null ? getTitle() : "null");
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{description:");
        stringBuilder.append(getDescription() != null ? getDescription() : "null");
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{thumbnailUrl:");
        stringBuilder.append(getThumbnailUrl() != null ? getThumbnailUrl() : "null");
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{userName:");
        stringBuilder.append(getUserName() != null ? getUserName() : "null");
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{createdAt:");
        stringBuilder.append(getCreatedAt() != null ? getCreatedAt() : "null");
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{city:");
        stringBuilder.append(getCity() != null ? getCity() : "null");
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{country:");
        stringBuilder.append(getCountry() != null ? getCountry() : "null");
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{location:");
        stringBuilder.append(getLocation() != null ? getLocation() : "null");
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{latitude:");
        stringBuilder.append(getLatitude() != null ? getLatitude() : "null");
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{longitude:");
        stringBuilder.append(getLongitude() != null ? getLongitude() : "null");
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{query:");
        stringBuilder.append(getQuery() != null ? getQuery() : "null");
        stringBuilder.append("}");
        stringBuilder.append("]");
        return stringBuilder.toString();
    }

    @Override
    public int hashCode() {
        String realmName = realm.getPath();
        String tableName = row.getTable().getName();
        long rowIndex = row.getIndex();

        int result = 17;
        result = 31 * result + ((realmName != null) ? realmName.hashCode() : 0);
        result = 31 * result + ((tableName != null) ? tableName.hashCode() : 0);
        result = 31 * result + (int) (rowIndex ^ (rowIndex >>> 32));
        return result;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TweetVoRealmProxy aTweetVo = (TweetVoRealmProxy)o;

        String path = realm.getPath();
        String otherPath = aTweetVo.realm.getPath();
        if (path != null ? !path.equals(otherPath) : otherPath != null) return false;;

        String tableName = row.getTable().getName();
        String otherTableName = aTweetVo.row.getTable().getName();
        if (tableName != null ? !tableName.equals(otherTableName) : otherTableName != null) return false;

        if (row.getIndex() != aTweetVo.row.getIndex()) return false;

        return true;
    }

}
