<commit_before>package com.danielesegato.adme;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

import com.danielesegato.adme.config.ADMEConfigUtils;
import com.danielesegato.adme.config.ADMEEntityConfig;
import com.danielesegato.adme.config.ADMEFieldConfig;
import com.danielesegato.adme.config.ADMEIndexConstraintConfig;
import com.danielesegato.adme.config.OnForeignUpdateDelete;
import com.danielesegato.adme.db.ADMESerializer;
import com.danielesegato.adme.db.ADMESerializerMapping;
import com.danielesegato.adme.utils.SQLStringHelper;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Android Database Made Easy library entry point.
 * <p/>
 * Utility methods to create and drop the entities in the database.
 */
public class ADME {

    private static final String TAG = ADME.class.getSimpleName();

    /**
     * Convert an entity row into it's Andoird {@link ContentValues} ready to use in an insert or update
     * query.
     * <p/>
     * If the class of the entityRow is not annotated with {@link com.danielesegato.adme.annotation.ADMEEntity}
     * this method will throw a RuntimeException.
     *
     * @param values             The ContentValues to recycle or null (one will be created), it will not
     *                           be cleared, it's the caller job to do so if you require it.
     * @param entityRow          The instance of the entity from which you want to extract values.
     * @param includeId          <em>True</em> if you want to include the ID in the content values,
     *                           <em>false</em> otherwise, if the id is autogenerated it will never be
     *                           included, regardless of the value you pass here
     * @param includeForeignKeys <em>True</em> to include foreign key, <em>false</em> otherwise (useful
     *                           if you need to use back references)
     * @return the ContentValues from the entity row
     */
    public static <T> ContentValues entityToContentValues(ContentValues values, T entityRow, boolean includeId, boolean includeForeignKeys) {
        Set<String> columns = getAllColumnsSet(entityRow.getClass(), includeId, includeForeignKeys);
        return entityToContentValues(values, entityRow, columns);
    }

    /**
     * Build a set with all the columns of of an entity
     *
     * @param entityClass        the entity class
     * @param <T>                the type of object
     * @param includeId          <em>True</em> if you want to include the ID in the content values,
     *                           <em>false</em> otherwise, if the id is autogenerated it will never be
     *                           included, regardless of the value you pass here
     * @param includeForeignKeys <em>True</em> to include foreign key, <em>false</em> otherwise (useful
     *                           if you need to use back references)
     * @return the complete set of columns for this entity
     */
    public static <T> Set<String> getAllColumnsSet(Class<T> entityClass, boolean includeId, boolean includeForeignKeys) {
        final ADMEEntityConfig<T> entityConfig = ADMEConfigUtils.lookupADMEEntityConfig(entityClass);
        Set<String> columns = new HashSet<String>();
        for (ADMEFieldConfig field : entityConfig.getFieldsConfig()) {
            if (field.isGeneratedId()) {
                continue;
            } else if (!includeId && field.isId()) {<commit_msg>Include generated ID when getting columns by table<commit_after>package com.danielesegato.adme;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

import com.danielesegato.adme.config.ADMEConfigUtils;
import com.danielesegato.adme.config.ADMEEntityConfig;
import com.danielesegato.adme.config.ADMEFieldConfig;
import com.danielesegato.adme.config.ADMEIndexConstraintConfig;
import com.danielesegato.adme.config.OnForeignUpdateDelete;
import com.danielesegato.adme.db.ADMESerializer;
import com.danielesegato.adme.db.ADMESerializerMapping;
import com.danielesegato.adme.utils.SQLStringHelper;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Android Database Made Easy library entry point.
 * <p/>
 * Utility methods to create and drop the entities in the database.
 */
public class ADME {

    private static final String TAG = ADME.class.getSimpleName();

    /**
     * Convert an entity row into it's Andoird {@link ContentValues} ready to use in an insert or update
     * query.
     * <p/>
     * If the class of the entityRow is not annotated with {@link com.danielesegato.adme.annotation.ADMEEntity}
     * this method will throw a RuntimeException.
     *
     * @param values             The ContentValues to recycle or null (one will be created), it will not
     *                           be cleared, it's the caller job to do so if you require it.
     * @param entityRow          The instance of the entity from which you want to extract values.
     * @param includeId          <em>True</em> if you want to include the ID in the content values,
     *                           <em>false</em> otherwise, if the id is autogenerated it will never be
     *                           included, regardless of the value you pass here
     * @param includeForeignKeys <em>True</em> to include foreign key, <em>false</em> otherwise (useful
     *                           if you need to use back references)
     * @return the ContentValues from the entity row
     */
    public static <T> ContentValues entityToContentValues(ContentValues values, T entityRow, boolean includeId, boolean includeForeignKeys) {
        Set<String> columns = getAllColumnsSet(entityRow.getClass(), includeId, includeForeignKeys);
        return entityToContentValues(values, entityRow, columns);
    }

    /**
     * Build a set with all the columns of of an entity
     *
     * @param entityClass        the entity class
     * @param <T>                the type of object
     * @param includeId          <em>True</em> if you want to include the ID in the content values,
     *                           <em>false</em> otherwise, if the id is autogenerated it will never be
     *                           included, regardless of the value you pass here
     * @param includeForeignKeys <em>True</em> to include foreign key, <em>false</em> otherwise (useful
     *                           if you need to use back references)
     * @return the complete set of columns for this entity
     */
    public static <T> Set<String> getAllColumnsSet(Class<T> entityClass, boolean includeId, boolean includeForeignKeys) {
        final ADMEEntityConfig<T> entityConfig = ADMEConfigUtils.lookupADMEEntityConfig(entityClass);
        Set<String> columns = new HashSet<String>();
        for (ADMEFieldConfig field : entityConfig.getFieldsConfig()) {
            if (!includeId && field.isGeneratedId()) {
                continue;
            } else if (!includeId && field.isId()) {
{'fraction_non_alphanumeric': 0.08079834824501032, 'fraction_numerical': 0.0, 'mean_word_length': 2.7725856697819315, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3745986', 'n_tokens_mistral': 1967, 'n_tokens_neox': 1950, 'n_words': 670}