<commit_before>package org.coner.core;

import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import org.coner.core.domain.CompetitionGroup;
import org.coner.core.domain.Event;
import org.coner.core.domain.HandicapGroup;
import org.coner.core.domain.Registration;
import org.coner.core.exception.EventRegistrationMismatchException;
import org.coner.core.gateway.CompetitionGroupGateway;
import org.coner.core.gateway.EventGateway;
import org.coner.core.gateway.HandicapGroupGateway;
import org.coner.core.gateway.RegistrationGateway;

import java.util.List;

/**
 * The ConerCoreService is the domain level implementation of all functionality in the Coner core project.
 */
public class ConerCoreService {

    private final EventGateway eventGateway;
    private final RegistrationGateway registrationGateway;
    private final HandicapGroupGateway handicapGroupGateway;
    private final CompetitionGroupGateway competitionGroupGateway;

    /**
     * Constructor for ConerCoreService.
     *
     * @param eventGateway            the EventGateway
     * @param registrationGateway     the RegistrationGateway
     * @param handicapGroupGateway    the HandicapGroupGateway
     * @param competitionGroupGateway the CompetitionGroupGateway
     */
    public ConerCoreService(EventGateway eventGateway,
                            RegistrationGateway registrationGateway,
                            HandicapGroupGateway handicapGroupGateway,
                            CompetitionGroupGateway competitionGroupGateway) {
        this.eventGateway = eventGateway;
        this.registrationGateway = registrationGateway;
        this.handicapGroupGateway = handicapGroupGateway;
        this.competitionGroupGateway = competitionGroupGateway;
    }

    /**
     * Get all events.
     *
     * @return a list of all events
     */
    public List<Event> getEvents() {
        return eventGateway.getAll();
    }

    /**
     * Add an event.
     *
     * @param event the Event entity to add
     */
    public void addEvent(Event event) {
        Preconditions.checkNotNull(event);
        eventGateway.create(event);
    }

    /**
     * Get an Event by id.
     *
     * @param id the id of the event
     * @return the event with id or null if not found
     */
    public Event getEvent(String id) {
        Preconditions.checkArgument(!Strings.isNullOrEmpty(id));
        return eventGateway.findById(id);
    }

    /**
     * Get a Registration by id.
     *
     * @param eventId        the id of the Event the Registration belongs to
     * @param registrationId the id of the Registration
     * @return the Registration with id or null if not found
     * @throws org.coner.core.exception.EventRegistrationMismatchException if the Registration's Event id doesn't match
     *                                                                     eventId
     */
    public Registration getRegistration(String eventId, String registrationId)
            throws EventRegistrationMismatchException {
        Preconditions.checkArgument(!Strings.isNullOrEmpty(eventId));
        Preconditions.checkArgument(!Strings.isNullOrEmpty(registrationId));
        Event event = eventGateway.findById(eventId);
        if (event == null) {
            return null;
        }
        Registration registration = registrationGateway.findById(registrationId);
        if (registration == null) {
            return null;
        }
        if (!registration.getEvent().getId().equals(eventId)) {
            throw new EventRegistrationMismatchException();
        }
        return registration;
    }

    /**
     * Add a registration entry.
     *
     * @param event        the Event the Registration is being added for
     * @param registration the Registration to add
     */
    public void addRegistration(Event event, Registration registration) {
        Preconditions.checkNotNull(registration);
        Preconditions.checkNotNull(event);
        registration.setEvent(event);
        registrationGateway.create(registration);
    }

    /**
     * Get all registrations for an event.
     *
     * @param event the event to get registrations
     * @return a list of all registrations for the event
     */
    public List<Registration> getRegistrations(Event event) {
        Preconditions.checkNotNull(event);
        return registrationGateway.getAllWith(event);
    }

    /**
     * Add a HandicapGroup.
     *
     * @param handicapGroup the HandicapGroup entity to add
     */
    public void addHandicapGroup(HandicapGroup handicapGroup) {
        Preconditions.checkNotNull(handicapGroup);
        handicapGroupGateway.create(handicapGroup);
    }

    /**
     * Add a competition group.
     *
     * @param competitionGroup the Event entity to add
     */
    public void addCompetitionGroup(CompetitionGroup competitionGroup) {
        Preconditions.checkNotNull(competitionGroup);
        competitionGroupGateway.create(competitionGroup);
    }

    /**
     * Get all HandicapGroups.
     *
     * @return a List of HandicapGroup.
     */
    public List<HandicapGroup> getHandicapGroups() {
        return handicapGroupGateway.getAll();
    }

    /**
     * Get a HandicapGroup by id.
     *
     * @param id the id of the HandicapGroup
     * @return the HandicapGroup with id or null if not found
     */
    public HandicapGroup getHandicapGroup(String id) {
        Preconditions.checkArgument(!Strings.isNullOrEmpty(id));
        return handicapGroupGateway.findById(id);
    }

    /**
     * Get all CompetitionGroups.
     *
     * @return a List of CompetitionGroup entities.
     */
    public List<CompetitionGroup> getCompetitionGroups() {
        return competitionGroupGateway.getAll();
    }

    /**
     * Get a CompetitionGroup by id.
     *
     * @param id the id of the CompetitionGroup
     * @return the CompetitionGroup with id or null if not found
     */
    public CompetitionGroup getCompetitionGroup(String id) {
        Preconditions.checkArgument(!Strings.isNullOrEmpty(id));
        return competitionGroupGateway.findById(id);
    }
}<commit_msg>Reorganize Handicap/Competition Group methods within ConerCoreService<commit_after>package org.coner.core;

import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import org.coner.core.domain.CompetitionGroup;
import org.coner.core.domain.Event;
import org.coner.core.domain.HandicapGroup;
import org.coner.core.domain.Registration;
import org.coner.core.exception.EventRegistrationMismatchException;
import org.coner.core.gateway.CompetitionGroupGateway;
import org.coner.core.gateway.EventGateway;
import org.coner.core.gateway.HandicapGroupGateway;
import org.coner.core.gateway.RegistrationGateway;

import java.util.List;

/**
 * The ConerCoreService is the domain level implementation of all functionality in the Coner core project.
 */
public class ConerCoreService {

    private final EventGateway eventGateway;
    private final RegistrationGateway registrationGateway;
    private final HandicapGroupGateway handicapGroupGateway;
    private final CompetitionGroupGateway competitionGroupGateway;

    /**
     * Constructor for ConerCoreService.
     *
     * @param eventGateway            the EventGateway
     * @param registrationGateway     the RegistrationGateway
     * @param handicapGroupGateway    the HandicapGroupGateway
     * @param competitionGroupGateway the CompetitionGroupGateway
     */
    public ConerCoreService(EventGateway eventGateway,
                            RegistrationGateway registrationGateway,
                            HandicapGroupGateway handicapGroupGateway,
                            CompetitionGroupGateway competitionGroupGateway) {
        this.eventGateway = eventGateway;
        this.registrationGateway = registrationGateway;
        this.handicapGroupGateway = handicapGroupGateway;
        this.competitionGroupGateway = competitionGroupGateway;
    }

    /**
     * Get all events.
     *
     * @return a list of all events
     */
    public List<Event> getEvents() {
        return eventGateway.getAll();
    }

    /**
     * Add an event.
     *
     * @param event the Event entity to add
     */
    public void addEvent(Event event) {
        Preconditions.checkNotNull(event);
        eventGateway.create(event);
    }

    /**
     * Get an Event by id.
     *
     * @param id the id of the event
     * @return the event with id or null if not found
     */
    public Event getEvent(String id) {
        Preconditions.checkArgument(!Strings.isNullOrEmpty(id));
        return eventGateway.findById(id);
    }

    /**
     * Get a Registration by id.
     *
     * @param eventId        the id of the Event the Registration belongs to
     * @param registrationId the id of the Registration
     * @return the Registration with id or null if not found
     * @throws org.coner.core.exception.EventRegistrationMismatchException if the Registration's Event id doesn't match
     *                                                                     eventId
     */
    public Registration getRegistration(String eventId, String registrationId)
            throws EventRegistrationMismatchException {
        Preconditions.checkArgument(!Strings.isNullOrEmpty(eventId));
        Preconditions.checkArgument(!Strings.isNullOrEmpty(registrationId));
        Event event = eventGateway.findById(eventId);
        if (event == null) {
            return null;
        }
        Registration registration = registrationGateway.findById(registrationId);
        if (registration == null) {
            return null;
        }
        if (!registration.getEvent().getId().equals(eventId)) {
            throw new EventRegistrationMismatchException();
        }
        return registration;
    }

    /**
     * Add a registration entry.
     *
     * @param event        the Event the Registration is being added for
     * @param registration the Registration to add
     */
    public void addRegistration(Event event, Registration registration) {
        Preconditions.checkNotNull(registration);
        Preconditions.checkNotNull(event);
        registration.setEvent(event);
        registrationGateway.create(registration);
    }

    /**
     * Get all registrations for an event.
     *
     * @param event the event to get registrations
     * @return a list of all registrations for the event
     */
    public List<Registration> getRegistrations(Event event) {
        Preconditions.checkNotNull(event);
        return registrationGateway.getAllWith(event);
    }

    /**
     * Add a competition group.
     *
     * @param competitionGroup the Event entity to add
     */
    public void addCompetitionGroup(CompetitionGroup competitionGroup) {
        Preconditions.checkNotNull(competitionGroup);
        competitionGroupGateway.create(competitionGroup);
    }

    /**
     * Get all CompetitionGroups.
     *
     * @return a List of CompetitionGroup entities.
     */
    public List<CompetitionGroup> getCompetitionGroups() {
        return competitionGroupGateway.getAll();
    }

    /**
     * Get a CompetitionGroup by id.
     *
     * @param id the id of the CompetitionGroup
     * @return the CompetitionGroup with id or null if not found
     */
    public CompetitionGroup getCompetitionGroup(String id) {
        Preconditions.checkArgument(!Strings.isNullOrEmpty(id));
        return competitionGroupGateway.findById(id);
    }

    /**
     * Add a HandicapGroup.
     *
     * @param handicapGroup the HandicapGroup entity to add
     */
    public void addHandicapGroup(HandicapGroup handicapGroup) {
        Preconditions.checkNotNull(handicapGroup);
        handicapGroupGateway.create(handicapGroup);
    }

    /**
     * Get all HandicapGroups.
     *
     * @return a List of HandicapGroup.
     */
    public List<HandicapGroup> getHandicapGroups() {
        return handicapGroupGateway.getAll();
    }

    /**
     * Get a HandicapGroup by id.
     *
     * @param id the id of the HandicapGroup
     * @return the HandicapGroup with id or null if not found
     */
    public HandicapGroup getHandicapGroup(String id) {
        Preconditions.checkArgument(!Strings.isNullOrEmpty(id));
        return handicapGroupGateway.findById(id);
    }
}
{'fraction_non_alphanumeric': 0.07619279454722493, 'fraction_numerical': 0.0, 'mean_word_length': 2.6324786324786325, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2369692', 'n_tokens_mistral': 3223, 'n_tokens_neox': 3204, 'n_words': 821}