Source:
private DBParameter populateDBParameter(List<String> fieldNames, List<String> initialIncludedFields, List<Object> initialArgs, String indexName, BasicDocumentRevision rev) { List<String> includeFieldNames = new ArrayList<String>(); includeFieldNames.addAll(initialIncludedFields); List<Object> args = new ArrayList<Object>(); args.addAll(initialArgs); for (String fieldName: fieldNames) { if (initialIncludedFields.contains(fieldName)) { continue; } Object value = ValueExtractor.extractValueForFieldName(fieldName, rev.getBody()); if (value != null) { if (value instanceof List && ((List) value).size() == 0) { continue; } includeFieldNames.add(fieldName); args.add(value); } } ContentValues contentValues = new ContentValues(); int argIndex = 0; for (String fieldName: includeFieldNames) { fieldName = String.format("\"%s\"", fieldName); Object argument = args.get(argIndex); if (argument instanceof Boolean) { contentValues.put(fieldName, (Boolean) argument); } else if (argument instanceof Byte) { contentValues.put(fieldName, (Byte) argument); } else if (argument instanceof byte[]) { contentValues.put(fieldName, (byte[]) argument); } else if (argument instanceof Double) { contentValues.put(fieldName, (Double) argument); } else if (argument instanceof Float) { contentValues.put(fieldName, (Float) argument); } else if (argument instanceof Integer) { contentValues.put(fieldName, (Integer) argument); } else if (argument instanceof Long) { contentValues.put(fieldName, (Long) argument); } else if (argument instanceof Short) { contentValues.put(fieldName, (Short) argument); } else if (argument instanceof String) { contentValues.put(fieldName, (String) argument); } else { contentValues.put(fieldName, (String) null); } argIndex = argIndex + 1; } String tableName = IndexManager.tableNameForIndex(indexName); return new DBParameter(tableName, contentValues); }

Target:
private DBParameter populateDBParameter(List<String> fieldNames, List<String> initialIncludedFields, List<Object> initialArgs, String indexName, BasicDocumentRevision rev) { List<String> includeFieldNames = new ArrayList<String>(); includeFieldNames.addAll(initialIncludedFields); List<Object> args = new ArrayList<Object>(); args.addAll(initialArgs); for (String fieldName: fieldNames) { if (initialIncludedFields.contains(fieldName)) { continue; } Object value = ValueExtractor.extractValueForFieldName(fieldName, rev.getBody()); if (value != null && !(value instanceof List && ((List) value).size() == 0)) { includeFieldNames.add(fieldName); args.add(value); } } ContentValues contentValues = new ContentValues(); int argIndex = 0; for (String fieldName: includeFieldNames) { fieldName = String.format("\"%s\"", fieldName); Object argument = args.get(argIndex); if (argument instanceof Boolean) { contentValues.put(fieldName, (Boolean) argument); } else if (argument instanceof Byte) { contentValues.put(fieldName, (Byte) argument); } else if (argument instanceof byte[]) { contentValues.put(fieldName, (byte[]) argument); } else if (argument instanceof Double) { contentValues.put(fieldName, (Double) argument); } else if (argument instanceof Float) { contentValues.put(fieldName, (Float) argument); } else if (argument instanceof Integer) { contentValues.put(fieldName, (Integer) argument); } else if (argument instanceof Long) { contentValues.put(fieldName, (Long) argument); } else if (argument instanceof Short) { contentValues.put(fieldName, (Short) argument); } else if (argument instanceof String) { contentValues.put(fieldName, (String) argument); } else { contentValues.put(fieldName, (String) null); } argIndex = argIndex + 1; } String tableName = IndexManager.tableNameForIndex(indexName); return new DBParameter(tableName, contentValues); }