package io.realm;


import android.util.JsonReader;
import android.util.JsonToken;
import com.mgdiez.data.bean.vo.tweet.IntegerVo;
import com.mgdiez.data.bean.vo.tweet.StatisticVo;
import com.mgdiez.data.bean.vo.tweet.StringVo;
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 StatisticVoRealmProxy extends StatisticVo
    implements RealmObjectProxy {

    static final class StatisticVoColumnInfo extends ColumnInfo {

        public final long idIndex;
        public final long stringValuesIndex;
        public final long integerValuesIndex;
        public final long nTweetsIndex;
        public final long typeIndex;
        public final long subTypeIndex;
        public final long dateGeneratedIndex;
        public final long selectedOptionIndex;

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

            this.stringValuesIndex = getValidColumnIndex(path, table, "StatisticVo", "stringValues");
            indicesMap.put("stringValues", this.stringValuesIndex);

            this.integerValuesIndex = getValidColumnIndex(path, table, "StatisticVo", "integerValues");
            indicesMap.put("integerValues", this.integerValuesIndex);

            this.nTweetsIndex = getValidColumnIndex(path, table, "StatisticVo", "nTweets");
            indicesMap.put("nTweets", this.nTweetsIndex);

            this.typeIndex = getValidColumnIndex(path, table, "StatisticVo", "type");
            indicesMap.put("type", this.typeIndex);

            this.subTypeIndex = getValidColumnIndex(path, table, "StatisticVo", "subType");
            indicesMap.put("subType", this.subTypeIndex);

            this.dateGeneratedIndex = getValidColumnIndex(path, table, "StatisticVo", "dateGenerated");
            indicesMap.put("dateGenerated", this.dateGeneratedIndex);

            this.selectedOptionIndex = getValidColumnIndex(path, table, "StatisticVo", "selectedOption");
            indicesMap.put("selectedOption", this.selectedOptionIndex);

            setIndicesMap(indicesMap);
        }
    }

    private final StatisticVoColumnInfo columnInfo;
    private RealmList<StringVo> stringValuesRealmList;
    private RealmList<IntegerVo> integerValuesRealmList;
    private static final List<String> FIELD_NAMES;
    static {
        List<String> fieldNames = new ArrayList<String>();
        fieldNames.add("id");
        fieldNames.add("stringValues");
        fieldNames.add("integerValues");
        fieldNames.add("nTweets");
        fieldNames.add("type");
        fieldNames.add("subType");
        fieldNames.add("dateGenerated");
        fieldNames.add("selectedOption");
        FIELD_NAMES = Collections.unmodifiableList(fieldNames);
    }

    StatisticVoRealmProxy(ColumnInfo columnInfo) {
        this.columnInfo = (StatisticVoColumnInfo) columnInfo;
    }

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

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

    @Override
    public RealmList<StringVo> getStringValues() {
        realm.checkIfValid();
        // use the cached value if available
        if (stringValuesRealmList != null) {
            return stringValuesRealmList;
        } else {
            LinkView linkView = row.getLinkList(columnInfo.stringValuesIndex);
            stringValuesRealmList = new RealmList<StringVo>(StringVo.class, linkView, realm);
            return stringValuesRealmList;
        }
    }

    @Override
    public void setStringValues(RealmList<StringVo> value) {
        realm.checkIfValid();
        LinkView links = row.getLinkList(columnInfo.stringValuesIndex);
        links.clear();
        if (value == null) {
            return;
        }
        for (RealmObject linkedObject : (RealmList<? extends RealmObject>) value) {
            if (!linkedObject.isValid()) {
                throw new IllegalArgumentException("Each element of 'value' must be a valid managed object.");
            }
            if (linkedObject.realm != this.realm) {
                throw new IllegalArgumentException("Each element of 'value' must belong to the same Realm.");
            }
            links.add(linkedObject.row.getIndex());
        }
    }

    @Override
    public RealmList<IntegerVo> getIntegerValues() {
        realm.checkIfValid();
        // use the cached value if available
        if (integerValuesRealmList != null) {
            return integerValuesRealmList;
        } else {
            LinkView linkView = row.getLinkList(columnInfo.integerValuesIndex);
            integerValuesRealmList = new RealmList<IntegerVo>(IntegerVo.class, linkView, realm);
            return integerValuesRealmList;
        }
    }

    @Override
    public void setIntegerValues(RealmList<IntegerVo> value) {
        realm.checkIfValid();
        LinkView links = row.getLinkList(columnInfo.integerValuesIndex);
        links.clear();
        if (value == null) {
            return;
        }
        for (RealmObject linkedObject : (RealmList<? extends RealmObject>) value) {
            if (!linkedObject.isValid()) {
                throw new IllegalArgumentException("Each element of 'value' must be a valid managed object.");
            }
            if (linkedObject.realm != this.realm) {
                throw new IllegalArgumentException("Each element of 'value' must belong to the same Realm.");
            }
            links.add(linkedObject.row.getIndex());
        }
    }

    @Override
    @SuppressWarnings("cast")
    public int getnTweets() {
        realm.checkIfValid();
        return (int) row.getLong(columnInfo.nTweetsIndex);
    }

    @Override
    public void setnTweets(int value) {
        realm.checkIfValid();
        row.setLong(columnInfo.nTweetsIndex, value);
    }

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

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

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

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

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

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

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

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

    public static Table initTable(ImplicitTransaction transaction) {
        if (!transaction.hasTable("class_StatisticVo")) {
            Table table = transaction.getTable("class_StatisticVo");
            table.addColumn(RealmFieldType.INTEGER, "id", Table.NOT_NULLABLE);
            if (!transaction.hasTable("class_StringVo")) {
                StringVoRealmProxy.initTable(transaction);
            }
            table.addColumnLink(RealmFieldType.LIST, "stringValues", transaction.getTable("class_StringVo"));
            if (!transaction.hasTable("class_IntegerVo")) {
                IntegerVoRealmProxy.initTable(transaction);
            }
            table.addColumnLink(RealmFieldType.LIST, "integerValues", transaction.getTable("class_IntegerVo"));
            table.addColumn(RealmFieldType.INTEGER, "nTweets", Table.NOT_NULLABLE);
            table.addColumn(RealmFieldType.STRING, "type", Table.NULLABLE);
            table.addColumn(RealmFieldType.STRING, "subType", Table.NULLABLE);
            table.addColumn(RealmFieldType.STRING, "dateGenerated", Table.NULLABLE);
            table.addColumn(RealmFieldType.STRING, "selectedOption", Table.NULLABLE);
            table.addSearchIndex(table.getColumnIndex("id"));
            table.setPrimaryKey("id");
            return table;
        }
        return transaction.getTable("class_StatisticVo");
    }

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

            final StatisticVoColumnInfo columnInfo = new StatisticVoColumnInfo(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 'int' 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("stringValues")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'stringValues'");
            }
            if (columnTypes.get("stringValues") != RealmFieldType.LIST) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'StringVo' for field 'stringValues'");
            }
            if (!transaction.hasTable("class_StringVo")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing class 'class_StringVo' for field 'stringValues'");
            }
            Table table_1 = transaction.getTable("class_StringVo");
            if (!table.getLinkTarget(columnInfo.stringValuesIndex).hasSameSchema(table_1)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid RealmList type for field 'stringValues': '" + table.getLinkTarget(columnInfo.stringValuesIndex).getName() + "' expected - was '" + table_1.getName() + "'");
            }
            if (!columnTypes.containsKey("integerValues")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'integerValues'");
            }
            if (columnTypes.get("integerValues") != RealmFieldType.LIST) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'IntegerVo' for field 'integerValues'");
            }
            if (!transaction.hasTable("class_IntegerVo")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing class 'class_IntegerVo' for field 'integerValues'");
            }
            Table table_2 = transaction.getTable("class_IntegerVo");
            if (!table.getLinkTarget(columnInfo.integerValuesIndex).hasSameSchema(table_2)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid RealmList type for field 'integerValues': '" + table.getLinkTarget(columnInfo.integerValuesIndex).getName() + "' expected - was '" + table_2.getName() + "'");
            }
            if (!columnTypes.containsKey("nTweets")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'nTweets' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("nTweets") != RealmFieldType.INTEGER) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'int' for field 'nTweets' in existing Realm file.");
            }
            if (table.isColumnNullable(columnInfo.nTweetsIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field 'nTweets' does support null values in the existing Realm file. Use corresponding boxed type for field 'nTweets' or migrate using io.realm.internal.Table.convertColumnToNotNullable().");
            }
            if (!columnTypes.containsKey("type")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'type' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("type") != RealmFieldType.STRING) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'String' for field 'type' in existing Realm file.");
            }
            if (!table.isColumnNullable(columnInfo.typeIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field 'type' is required. Either set @Required to field 'type' or migrate using io.realm.internal.Table.convertColumnToNullable().");
            }
            if (!columnTypes.containsKey("subType")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'subType' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("subType") != RealmFieldType.STRING) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'String' for field 'subType' in existing Realm file.");
            }
            if (!table.isColumnNullable(columnInfo.subTypeIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field 'subType' is required. Either set @Required to field 'subType' or migrate using io.realm.internal.Table.convertColumnToNullable().");
            }
            if (!columnTypes.containsKey("dateGenerated")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'dateGenerated' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("dateGenerated") != RealmFieldType.STRING) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'String' for field 'dateGenerated' in existing Realm file.");
            }
            if (!table.isColumnNullable(columnInfo.dateGeneratedIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field 'dateGenerated' is required. Either set @Required to field 'dateGenerated' or migrate using io.realm.internal.Table.convertColumnToNullable().");
            }
            if (!columnTypes.containsKey("selectedOption")) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'selectedOption' in existing Realm file. Either remove field or migrate using io.realm.internal.Table.addColumn().");
            }
            if (columnTypes.get("selectedOption") != RealmFieldType.STRING) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Invalid type 'String' for field 'selectedOption' in existing Realm file.");
            }
            if (!table.isColumnNullable(columnInfo.selectedOptionIndex)) {
                throw new RealmMigrationNeededException(transaction.getPath(), "Field 'selectedOption' is required. Either set @Required to field 'selectedOption' or migrate using io.realm.internal.Table.convertColumnToNullable().");
            }
            return columnInfo;
        } else {
            throw new RealmMigrationNeededException(transaction.getPath(), "The StatisticVo class is missing from the schema for this Realm.");
        }
    }

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

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

    @SuppressWarnings("cast")
    public static StatisticVo createOrUpdateUsingJsonObject(Realm realm, JSONObject json, boolean update)
        throws JSONException {
        StatisticVo obj = null;
        if (update) {
            Table table = realm.getTable(StatisticVo.class);
            long pkColumnIndex = table.getPrimaryKey();
            if (!json.isNull("id")) {
                long rowIndex = table.findFirstLong(pkColumnIndex, json.getLong("id"));
                if (rowIndex != TableOrView.NO_MATCH) {
                    obj = new StatisticVoRealmProxy(realm.schema.getColumnInfo(StatisticVo.class));
                    obj.realm = realm;
                    obj.row = table.getUncheckedRow(rowIndex);
                }
            }
        }
        if (obj == null) {
            if (json.has("id")) {
                if (json.isNull("id")) {
                    obj = realm.createObject(StatisticVo.class, null);
                } else {
                    obj = realm.createObject(StatisticVo.class, json.getInt("id"));
                }
            } else {
                obj = realm.createObject(StatisticVo.class);
            }
        }
        if (json.has("id")) {
            if (json.isNull("id")) {
                throw new IllegalArgumentException("Trying to set non-nullable field id to null.");
            } else {
                obj.setId((int) json.getInt("id"));
            }
        }
        if (json.has("stringValues")) {
            if (json.isNull("stringValues")) {
                obj.setStringValues(null);
            } else {
                obj.getStringValues().clear();
                JSONArray array = json.getJSONArray("stringValues");
                for (int i = 0; i < array.length(); i++) {
                    com.mgdiez.data.bean.vo.tweet.StringVo item = StringVoRealmProxy.createOrUpdateUsingJsonObject(realm, array.getJSONObject(i), update);
                    obj.getStringValues().add(item);
                }
            }
        }
        if (json.has("integerValues")) {
            if (json.isNull("integerValues")) {
                obj.setIntegerValues(null);
            } else {
                obj.getIntegerValues().clear();
                JSONArray array = json.getJSONArray("integerValues");
                for (int i = 0; i < array.length(); i++) {
                    com.mgdiez.data.bean.vo.tweet.IntegerVo item = IntegerVoRealmProxy.createOrUpdateUsingJsonObject(realm, array.getJSONObject(i), update);
                    obj.getIntegerValues().add(item);
                }
            }
        }
        if (json.has("nTweets")) {
            if (json.isNull("nTweets")) {
                throw new IllegalArgumentException("Trying to set non-nullable field nTweets to null.");
            } else {
                obj.setnTweets((int) json.getInt("nTweets"));
            }
        }
        if (json.has("type")) {
            if (json.isNull("type")) {
                obj.setType(null);
            } else {
                obj.setType((String) json.getString("type"));
            }
        }
        if (json.has("subType")) {
            if (json.isNull("subType")) {
                obj.setSubType(null);
            } else {
                obj.setSubType((String) json.getString("subType"));
            }
        }
        if (json.has("dateGenerated")) {
            if (json.isNull("dateGenerated")) {
                obj.setDateGenerated(null);
            } else {
                obj.setDateGenerated((String) json.getString("dateGenerated"));
            }
        }
        if (json.has("selectedOption")) {
            if (json.isNull("selectedOption")) {
                obj.setSelectedOption(null);
            } else {
                obj.setSelectedOption((String) json.getString("selectedOption"));
            }
        }
        return obj;
    }

    @SuppressWarnings("cast")
    public static StatisticVo createUsingJsonStream(Realm realm, JsonReader reader)
        throws IOException {
        StatisticVo obj = realm.createObject(StatisticVo.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((int) reader.nextInt());
                }
            } else if (name.equals("stringValues")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setStringValues(null);
                } else {
                    reader.beginArray();
                    while (reader.hasNext()) {
                        com.mgdiez.data.bean.vo.tweet.StringVo item = StringVoRealmProxy.createUsingJsonStream(realm, reader);
                        obj.getStringValues().add(item);
                    }
                    reader.endArray();
                }
            } else if (name.equals("integerValues")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setIntegerValues(null);
                } else {
                    reader.beginArray();
                    while (reader.hasNext()) {
                        com.mgdiez.data.bean.vo.tweet.IntegerVo item = IntegerVoRealmProxy.createUsingJsonStream(realm, reader);
                        obj.getIntegerValues().add(item);
                    }
                    reader.endArray();
                }
            } else if (name.equals("nTweets")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    throw new IllegalArgumentException("Trying to set non-nullable field nTweets to null.");
                } else {
                    obj.setnTweets((int) reader.nextInt());
                }
            } else if (name.equals("type")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setType(null);
                } else {
                    obj.setType((String) reader.nextString());
                }
            } else if (name.equals("subType")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setSubType(null);
                } else {
                    obj.setSubType((String) reader.nextString());
                }
            } else if (name.equals("dateGenerated")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setDateGenerated(null);
                } else {
                    obj.setDateGenerated((String) reader.nextString());
                }
            } else if (name.equals("selectedOption")) {
                if (reader.peek() == JsonToken.NULL) {
                    reader.skipValue();
                    obj.setSelectedOption(null);
                } else {
                    obj.setSelectedOption((String) reader.nextString());
                }
            } else {
                reader.skipValue();
            }
        }
        reader.endObject();
        return obj;
    }

    public static StatisticVo copyOrUpdate(Realm realm, StatisticVo object, boolean update, Map<RealmObject,RealmObjectProxy> cache) {
        if (object.realm != null && object.realm.getPath().equals(realm.getPath())) {
            return object;
        }
        StatisticVo realmObject = null;
        boolean canUpdate = update;
        if (canUpdate) {
            Table table = realm.getTable(StatisticVo.class);
            long pkColumnIndex = table.getPrimaryKey();
            long rowIndex = table.findFirstLong(pkColumnIndex, object.getId());
            if (rowIndex != TableOrView.NO_MATCH) {
                realmObject = new StatisticVoRealmProxy(realm.schema.getColumnInfo(StatisticVo.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 StatisticVo copy(Realm realm, StatisticVo newObject, boolean update, Map<RealmObject,RealmObjectProxy> cache) {
        StatisticVo realmObject = realm.createObject(StatisticVo.class, newObject.getId());
        cache.put(newObject, (RealmObjectProxy) realmObject);
        realmObject.setId(newObject.getId());

        RealmList<StringVo> stringValuesList = newObject.getStringValues();
        if (stringValuesList != null) {
            RealmList<StringVo> stringValuesRealmList = realmObject.getStringValues();
            for (int i = 0; i < stringValuesList.size(); i++) {
                StringVo stringValuesItem = stringValuesList.get(i);
                StringVo cachestringValues = (StringVo) cache.get(stringValuesItem);
                if (cachestringValues != null) {
                    stringValuesRealmList.add(cachestringValues);
                } else {
                    stringValuesRealmList.add(StringVoRealmProxy.copyOrUpdate(realm, stringValuesList.get(i), update, cache));
                }
            }
        }


        RealmList<IntegerVo> integerValuesList = newObject.getIntegerValues();
        if (integerValuesList != null) {
            RealmList<IntegerVo> integerValuesRealmList = realmObject.getIntegerValues();
            for (int i = 0; i < integerValuesList.size(); i++) {
                IntegerVo integerValuesItem = integerValuesList.get(i);
                IntegerVo cacheintegerValues = (IntegerVo) cache.get(integerValuesItem);
                if (cacheintegerValues != null) {
                    integerValuesRealmList.add(cacheintegerValues);
                } else {
                    integerValuesRealmList.add(IntegerVoRealmProxy.copyOrUpdate(realm, integerValuesList.get(i), update, cache));
                }
            }
        }

        realmObject.setnTweets(newObject.getnTweets());
        realmObject.setType(newObject.getType());
        realmObject.setSubType(newObject.getSubType());
        realmObject.setDateGenerated(newObject.getDateGenerated());
        realmObject.setSelectedOption(newObject.getSelectedOption());
        return realmObject;
    }

    public static StatisticVo createDetachedCopy(StatisticVo realmObject, int currentDepth, int maxDepth, Map<RealmObject, CacheData<RealmObject>> cache) {
        if (currentDepth > maxDepth || realmObject == null) {
            return null;
        }
        CacheData<StatisticVo> cachedObject = (CacheData) cache.get(realmObject);
        StatisticVo 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 StatisticVo();
            cache.put(realmObject, new RealmObjectProxy.CacheData<RealmObject>(currentDepth, standaloneObject));
        }
        standaloneObject.setId(realmObject.getId());

        // Deep copy of stringValues
        if (currentDepth == maxDepth) {
            standaloneObject.setStringValues(null);
        } else {
            RealmList<StringVo> managedstringValuesList = realmObject.getStringValues();
            RealmList<StringVo> standalonestringValuesList = new RealmList<StringVo>();
            standaloneObject.setStringValues(standalonestringValuesList);
            int nextDepth = currentDepth + 1;
            int size = managedstringValuesList.size();
            for (int i = 0; i < size; i++) {
                StringVo item = StringVoRealmProxy.createDetachedCopy(managedstringValuesList.get(i), nextDepth, maxDepth, cache);
                standalonestringValuesList.add(item);
            }
        }

        // Deep copy of integerValues
        if (currentDepth == maxDepth) {
            standaloneObject.setIntegerValues(null);
        } else {
            RealmList<IntegerVo> managedintegerValuesList = realmObject.getIntegerValues();
            RealmList<IntegerVo> standaloneintegerValuesList = new RealmList<IntegerVo>();
            standaloneObject.setIntegerValues(standaloneintegerValuesList);
            int nextDepth = currentDepth + 1;
            int size = managedintegerValuesList.size();
            for (int i = 0; i < size; i++) {
                IntegerVo item = IntegerVoRealmProxy.createDetachedCopy(managedintegerValuesList.get(i), nextDepth, maxDepth, cache);
                standaloneintegerValuesList.add(item);
            }
        }
        standaloneObject.setnTweets(realmObject.getnTweets());
        standaloneObject.setType(realmObject.getType());
        standaloneObject.setSubType(realmObject.getSubType());
        standaloneObject.setDateGenerated(realmObject.getDateGenerated());
        standaloneObject.setSelectedOption(realmObject.getSelectedOption());
        return standaloneObject;
    }

    static StatisticVo update(Realm realm, StatisticVo realmObject, StatisticVo newObject, Map<RealmObject, RealmObjectProxy> cache) {
        RealmList<StringVo> stringValuesList = newObject.getStringValues();
        RealmList<StringVo> stringValuesRealmList = realmObject.getStringValues();
        stringValuesRealmList.clear();
        if (stringValuesList != null) {
            for (int i = 0; i < stringValuesList.size(); i++) {
                StringVo stringValuesItem = stringValuesList.get(i);
                StringVo cachestringValues = (StringVo) cache.get(stringValuesItem);
                if (cachestringValues != null) {
                    stringValuesRealmList.add(cachestringValues);
                } else {
                    stringValuesRealmList.add(StringVoRealmProxy.copyOrUpdate(realm, stringValuesList.get(i), true, cache));
                }
            }
        }
        RealmList<IntegerVo> integerValuesList = newObject.getIntegerValues();
        RealmList<IntegerVo> integerValuesRealmList = realmObject.getIntegerValues();
        integerValuesRealmList.clear();
        if (integerValuesList != null) {
            for (int i = 0; i < integerValuesList.size(); i++) {
                IntegerVo integerValuesItem = integerValuesList.get(i);
                IntegerVo cacheintegerValues = (IntegerVo) cache.get(integerValuesItem);
                if (cacheintegerValues != null) {
                    integerValuesRealmList.add(cacheintegerValues);
                } else {
                    integerValuesRealmList.add(IntegerVoRealmProxy.copyOrUpdate(realm, integerValuesList.get(i), true, cache));
                }
            }
        }
        realmObject.setnTweets(newObject.getnTweets());
        realmObject.setType(newObject.getType());
        realmObject.setSubType(newObject.getSubType());
        realmObject.setDateGenerated(newObject.getDateGenerated());
        realmObject.setSelectedOption(newObject.getSelectedOption());
        return realmObject;
    }

    @Override
    public String toString() {
        if (!isValid()) {
            return "Invalid object";
        }
        StringBuilder stringBuilder = new StringBuilder("StatisticVo = [");
        stringBuilder.append("{id:");
        stringBuilder.append(getId());
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{stringValues:");
        stringBuilder.append("RealmList<StringVo>[").append(getStringValues().size()).append("]");
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{integerValues:");
        stringBuilder.append("RealmList<IntegerVo>[").append(getIntegerValues().size()).append("]");
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{nTweets:");
        stringBuilder.append(getnTweets());
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{type:");
        stringBuilder.append(getType() != null ? getType() : "null");
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{subType:");
        stringBuilder.append(getSubType() != null ? getSubType() : "null");
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{dateGenerated:");
        stringBuilder.append(getDateGenerated() != null ? getDateGenerated() : "null");
        stringBuilder.append("}");
        stringBuilder.append(",");
        stringBuilder.append("{selectedOption:");
        stringBuilder.append(getSelectedOption() != null ? getSelectedOption() : "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;
        StatisticVoRealmProxy aStatisticVo = (StatisticVoRealmProxy)o;

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

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

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

        return true;
    }

}
