<commit_before>package com.alexstyl.specialdates.events;

import android.content.ContentValues;

import com.alexstyl.specialdates.Marshaller;
import com.alexstyl.specialdates.contact.Contact;
import com.alexstyl.specialdates.date.ContactEvent;
import com.alexstyl.specialdates.date.DateDisplayStringCreator;

import java.util.List;

public class ContactEventsMarshaller implements Marshaller<List<ContactEvent>> {

    @Override
    public ContentValues[] marshall(List<ContactEvent> item) {
        ContentValues[] returningValues = new ContentValues[item.size()];
        for (int i = 0; i < item.size(); i++) {
            ContactEvent event = item.get(i);
            returningValues[i] = createValuesFor(event);
        }
        return returningValues;
    }

    private ContentValues createValuesFor(ContactEvent event) {
        Contact contact = event.getContact();

        ContentValues values = new ContentValues(4);
        values.put(PeopleEventsContract.PeopleEvents.CONTACT_ID, contact.getContactID());
        values.put(PeopleEventsContract.PeopleEvents.SOURCE, ContactSource.DEVICE);
        values.put(PeopleEventsContract.PeopleEvents.DISPLAY_NAME, contact.getDisplayName().toString());

        String date = DateDisplayStringCreator.getInstance().stringOf(event.getDate());
        values.put(PeopleEventsContract.PeopleEvents.DATE, date);

        values.put(PeopleEventsContract.PeopleEvents.EVENT_TYPE, PeopleEventsContract.PeopleEvents.TYPE_NAMEDAY);
        return values;
    }
}
<commit_msg>Create specific type for each event type<commit_after>package com.alexstyl.specialdates.events;

import android.content.ContentValues;

import com.alexstyl.specialdates.Marshaller;
import com.alexstyl.specialdates.contact.Contact;
import com.alexstyl.specialdates.date.ContactEvent;
import com.alexstyl.specialdates.date.DateDisplayStringCreator;
import com.novoda.notils.exception.DeveloperError;

import java.util.List;

public class ContactEventsMarshaller implements Marshaller<List<ContactEvent>> {

    @Override
    public ContentValues[] marshall(List<ContactEvent> item) {
        ContentValues[] returningValues = new ContentValues[item.size()];
        for (int i = 0; i < item.size(); i++) {
            ContactEvent event = item.get(i);
            returningValues[i] = createValuesFor(event);
        }
        return returningValues;
    }

    private ContentValues createValuesFor(ContactEvent event) {
        Contact contact = event.getContact();

        ContentValues values = new ContentValues(4);
        values.put(PeopleEventsContract.PeopleEvents.CONTACT_ID, contact.getContactID());
        values.put(PeopleEventsContract.PeopleEvents.SOURCE, ContactSource.DEVICE);
        values.put(PeopleEventsContract.PeopleEvents.DISPLAY_NAME, contact.getDisplayName().toString());

        String date = DateDisplayStringCreator.getInstance().stringOf(event.getDate());
        values.put(PeopleEventsContract.PeopleEvents.DATE, date);

        values.put(PeopleEventsContract.PeopleEvents.EVENT_TYPE, getTypeFor(event));
        return values;
    }

    private int getTypeFor(ContactEvent event) {
        switch (event.getType()) {
            case BIRTHDAY:
                return EventColumns.TYPE_BIRTHDAY;
            case NAMEDAY:
                return EventColumns.TYPE_NAMEDAY;
        }
        throw new DeveloperError(event.getType() + " has no EventColumn reference");
    }

}

{'fraction_non_alphanumeric': 0.09813628421665696, 'fraction_numerical': 0.0011648223645894002, 'mean_word_length': 3.810924369747899, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4048379', 'n_tokens_mistral': 933, 'n_tokens_neox': 915, 'n_words': 165}