<commit_before>/**
 *
 * EventoZero - Advanced event factory and executor for Bukkit and Spigot.
 * Copyright � 2016 BlackHub OS and contributors.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */
package br.com.blackhubos.eventozero.factory;

import java.util.HashSet;
import java.util.Optional;
import java.util.Set;

import org.apache.commons.lang.NullArgumentException;
import org.bukkit.entity.Player;

public class EventHandler {

    private final Set<Event> events;

    public EventHandler() {
        this.events = new HashSet<>();
    }

    public Optional<Event> getEventByName(final String name) {
        for (Event e : getEvents()) {
            if (e.getEventName().equals(name)) {
                return Optional.of(e);
            }
        }
        return Optional.empty();
    }

    public Optional<Event> getEventByPlayer(final Player player) {
        for (Event e : getEvents()) {
            if (e.hasPlayerJoined(player)) {
                return Optional.of(e);
            }
        }
        return Optional.empty();
    }

    public Set<Event> getEvents() {
        return this.events;

    }

    public void loadEvent(final Event event) {
        if (event != null) {
            throw new NullArgumentException("Event is null");
        }
        events.add(event);
    }

}<commit_msg>Usando preconditions<commit_after>/**
 *
 * EventoZero - Advanced event factory and executor for Bukkit and Spigot.
 * Copyright � 2016 BlackHub OS and contributors.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */
package br.com.blackhubos.eventozero.factory;

import java.util.HashSet;
import java.util.Optional;
import java.util.Set;

import org.apache.commons.lang.NullArgumentException;
import org.bukkit.entity.Player;

import com.google.common.base.Preconditions;

public class EventHandler {

    private final Set<Event> events;

    public EventHandler() {
        this.events = new HashSet<>();
    }

    public Optional<Event> getEventByName(final String name) {
        for (Event e : getEvents()) {
            if (e.getEventName().equals(name)) {
                return Optional.of(e);
            }
        }
        return Optional.empty();
    }

    public Optional<Event> getEventByPlayer(final Player player) {
        for (Event e : getEvents()) {
            if (e.hasPlayerJoined(player)) {
                return Optional.of(e);
            }
        }
        return Optional.empty();
    }

    public Set<Event> getEvents() {
        return this.events;

    }

    public void loadEvent(final Event event) {
        Preconditions.checkNotNull(event, "Event is null");
        events.add(event);
    }

}
{'fraction_non_alphanumeric': 0.09187370600414078, 'fraction_numerical': 0.002587991718426501, 'mean_word_length': 2.6985645933014353, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2401350', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1020, 'n_words': 379}