<commit_before>/**
 * Entity Essentials -- A Component-based Entity System
 *
 * Copyright (C) 2015 <NAME> <<EMAIL>>,
 *                    <NAME> <<EMAIL>>
 *
 *     This file is part of Entity Essentials.
 *
 *     Entity Essentials is free software; you can redistribute it and/or
 *     modify it under the terms of the GNU Lesser General Public License
 *     as published by the Free Software Foundation, either version 3 of
 *     the License, or any later version.
 *
 *     Entity Essentials 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
 *     Lesser General Public License for more details.
 *
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.jayware.e2.entity.api;


import org.jayware.e2.event.api.DeclarativeSanityChecker;
import org.jayware.e2.event.api.EventType.RootEvent;
import org.jayware.e2.event.api.SanityCheck;

import static org.jayware.e2.entity.api.EntityEvent.ChildrenEntityEvent.ChildRefParam;
import static org.jayware.e2.entity.api.EntityEvent.EntityChangedEvent.EntityRefParam;


@SanityCheck(EntityEvent.EntityEventSanityChecker.class)
public interface EntityEvent
extends RootEvent
{
    /**
     * The {@link EntityPath} of the entity which is subject of the event.
     */
    String EntityPathParam = "org.jayware.e2.event.param.EntityPath";

    interface CreateEntityEvent extends EntityEvent
    {
        /**
         * The id ({@link String}) of the entity which is subject of the event.
         */
        String EntityIdParam = "org.jayware.e2.event.param.EntityId";

        /**
         * The {@link EntityRef} of the entity which was created due to this event.
         */
        String EntityRefParam = "org.jayware.e2.event.param.EntityRef";
    }

    interface EntityCreatedEvent extends EntityEvent {}

    interface EntityDeletedEvent extends EntityEvent {}

    interface DeleteEntityEvent extends EntityEvent {}

    interface DeleteAllEntitiesEvent extends EntityEvent {}

    interface EntityDeletingEvent extends EntityEvent {}

    @SanityCheck(EntityChangedEvent.EntityChangedEventSanityChecker.class)
    interface EntityChangedEvent extends EntityEvent
    {
        /**
         * The {@link EntityRef} of the entity which is subject of the event.
         */
        String EntityRefParam = "org.jayware.e2.event.param.EntityRef";

        class EntityChangedEventSanityChecker
        extends DeclarativeSanityChecker
        {
            @Override
            protected void setup(SanityCheckerRuleBuilder checker)
            {
                checker.check(EntityChangedEvent.class).param(EntityRefParam, "EntityRefParam").notNull().instanceOf(EntityRef.class).done();
            }
        }
    }

    interface ChildrenEntityEvent extends EntityChangedEvent
    {
        /**
         * The {@link EntityRef} of the child which is subject of the event.
         */
        String ChildRefParam = "org.jayware.e2.event.param.ChildRef";
    }

    interface ChildAddedEntityEvent extends ChildrenEntityEvent {}

    interface ChildRemovedEntityEvent extends ChildrenEntityEvent {}

    class EntityEventSanityChecker
    extends DeclarativeSanityChecker
    {
        @Override
        protected void setup(SanityCheckerRuleBuilder checker)
        {
            // TODO: Create new checks according to the new query-api!
//            checker.check(EntityEvent.class).param(EntityPathParam, "EntityPathParam").instanceOf(EntityPath.class).notNull().done();
            checker.check(EntityChangedEvent.class).param(EntityRefParam, "EntityRefParam").instanceOf(EntityRef.class).notNull().done();
            checker.check(ChildrenEntityEvent.class).param(ChildRefParam, "ChildRefParam").instanceOf(EntityRef.class).notNull().done();
        }
    }
}
<commit_msg>Wrote descriptions to EntityEvents. #34<commit_after>/**
 * Entity Essentials -- A Component-based Entity System
 *
 * Copyright (C) 2015 <NAME> <<EMAIL>>,
 *                    <NAME> <<EMAIL>>
 *
 *     This file is part of Entity Essentials.
 *
 *     Entity Essentials is free software; you can redistribute it and/or
 *     modify it under the terms of the GNU Lesser General Public License
 *     as published by the Free Software Foundation, either version 3 of
 *     the License, or any later version.
 *
 *     Entity Essentials 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
 *     Lesser General Public License for more details.
 *
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.jayware.e2.entity.api;


import org.jayware.e2.context.api.Context;
import org.jayware.e2.event.api.DeclarativeSanityChecker;
import org.jayware.e2.event.api.EventType.RootEvent;
import org.jayware.e2.event.api.Presence;
import org.jayware.e2.event.api.SanityCheck;

import static org.jayware.e2.entity.api.EntityEvent.EntityChangedEvent.EntityChangedEventSanityChecker;


@SanityCheck(EntityEvent.EntityEventSanityChecker.class)
public interface EntityEvent
extends RootEvent
{
    /**
     * The {@link EntityPath} of the entity which is subject of the event.
     */
    @Deprecated
    String EntityPathParam = "org.jayware.e2.event.param.EntityPath";

    /**
     * The id ({@link String}) of the entity which is subject of the event.
     */
    String EntityIdParam = "org.jayware.e2.event.param.EntityId";

    /**
     * The {@link EntityRef} of the entity which was created due to this event.
     */
    String EntityRefParam = "org.jayware.e2.event.param.EntityRef";

    /**
     * Signals the creation of an entity.
     * <p>
     * <b>Parameters:</b>
     * <table>
     *     <tr><td>{@link EntityEvent#ContextParam}</td><td>{@link Presence#Required}</td></tr>
     *     <tr><td>{@link EntityEvent#EntityIdParam}</td><td>{@link Presence#Optional}</td></tr>
     * </table>
     */
    @SanityCheck(CreateEntityEventSanityChecker.class)
    interface CreateEntityEvent extends EntityEvent {}

    /**
     * Signals that an entity has been created.
     * <p>
     * <b>Parameters:</b>
     * <table>
     *     <tr><td>{@link EntityEvent#ContextParam}</td><td>{@link Presence#Required}</td></tr>
     *     <tr><td>{@link EntityEvent#EntityIdParam}</td><td>{@link Presence#Required}</td></tr>
     *     <tr><td>{@link EntityEvent#EntityRefParam}</td><td>{@link Presence#Required}</td></tr>
     * </table>
     */
    @SanityCheck(EntityCreatedEventSanityChecker.class)
    interface EntityCreatedEvent extends EntityEvent {}

    /**
     * Signals the deletion of an entity.
     * <p>
     * <b>Parameters:</b>
     * <table>
     *     <tr><td>{@link EntityEvent#ContextParam}</td><td>{@link Presence#Required}</td></tr>
     *     <tr><td>{@link EntityEvent#EntityIdParam}</td><td>{@link Presence#Required}</td></tr>
     *     <tr><td>{@link EntityEvent#EntityRefParam}</td><td>{@link Presence#Required}</td></tr>
     * </table>
     */
    @SanityCheck(DeleteEntityEventSanityChecker.class)
    interface DeleteEntityEvent extends EntityEvent {}

    /**
     * Signals that an entity has been deleted.
     * <p>
     * <b>Parameters:</b>
     * <table>
     *     <tr><td>{@link EntityEvent#ContextParam}</td><td>{@link Presence#Required}</td></tr>
     *     <tr><td>{@link EntityEvent#EntityIdParam}</td><td>{@link Presence#Required}</td></tr>
     *     <tr><td>{@link EntityEvent#EntityRefParam}</td><td>{@link Presence#Required}</td></tr>
     * </table>
     */
    @SanityCheck(EntityDeletedEventSanityChecker.class)
    interface EntityDeletedEvent extends EntityEvent {}

    /**
     * Signals that an entity is going to be deleted.
     * <p>
     * <b>Parameters:</b>
     * <table>
     *     <tr><td>{@link EntityEvent#ContextParam}</td><td>{@link Presence#Required}</td></tr>
     *     <tr><td>{@link EntityEvent#EntityIdParam}</td><td>{@link Presence#Required}</td></tr>
     *     <tr><td>{@link EntityEvent#EntityRefParam}</td><td>{@link Presence#Required}</td></tr>
     * </table>
     */
    @SanityCheck(EntityDeletingEventSanityChecker.class)
    interface EntityDeletingEvent extends EntityEvent {}

    /**
     * Signals the deletion of all entities within a {@link Context}.
     * <p>
     * <b>Parameters:</b>
     * <table>
     *     <tr><td>{@link EntityEvent#ContextParam}</td><td>{@link Presence#Required}</td></tr>
     * </table>
     */
    interface DeleteAllEntitiesEvent extends EntityEvent {}

    @SanityCheck(EntityChangedEventSanityChecker.class)
    interface EntityChangedEvent extends EntityEvent
    {
        /**
         * The {@link EntityRef} of the entity which is subject of the event.
         */
        String EntityRefParam = "org.jayware.e2.event.param.EntityRef";

        class EntityChangedEventSanityChecker
        extends DeclarativeSanityChecker
        {
            @Override
            protected void setup(SanityCheckerRuleBuilder checker)
            {
                checker.check(EntityChangedEvent.class).param(EntityRefParam, "EntityRefParam").notNull().instanceOf(EntityRef.class).done();
            }
        }
    }

    @Deprecated
    interface ChildrenEntityEvent extends EntityChangedEvent
    {
        /**
         * The {@link EntityRef} of the child which is subject of the event.
         */
        String ChildRefParam = "org.jayware.e2.event.param.ChildRef";
    }

    @Deprecated
    interface ChildAddedEntityEvent extends ChildrenEntityEvent {}

    @Deprecated
    interface ChildRemovedEntityEvent extends ChildrenEntityEvent {}

    class EntityEventSanityChecker
    extends DeclarativeSanityChecker
    {
        @Override
        protected void setup(SanityCheckerRuleBuilder checker)
        {
            // TODO: Create new checks according to the new query-api!
//            checker.check(EntityEvent.class).param(EntityPathParam, "EntityPathParam").instanceOf(EntityPath.class).notNull().done();
            checker.check(EntityChangedEvent.class).param(EntityRefParam, "EntityRefParam").instanceOf(EntityRef.class).notNull().done();
//            checker.check(ChildrenEntityEvent.class).param(ChildRefParam, "ChildRefParam").instanceOf(EntityRef.class).notNull().done();
        }
    }

    class CreateEntityEventSanityChecker
    extends DeclarativeSanityChecker
    {
        @Override
        protected void setup(SanityCheckerRuleBuilder checker)
        {
            checker.check(CreateEntityEvent.class).param(EntityIdParam, "EntityIdParam").instanceOf(String.class).done();
        }
    }

    class EntityCreatedEventSanityChecker
    extends DeclarativeSanityChecker
    {
        @Override
        protected void setup(SanityCheckerRuleBuilder checker)
        {
            checker.check(EntityCreatedEvent.class).param(EntityIdParam, "EntityIdParam").instanceOf(String.class).notNull().done();
            checker.check(EntityCreatedEvent.class).param(EntityRefParam, "EntityRefParam").instanceOf(EntityRef.class).notNull().done();
        }
    }

    class DeleteEntityEventSanityChecker
    extends DeclarativeSanityChecker
    {
        @Override
        protected void setup(SanityCheckerRuleBuilder checker)
        {
            checker.check(EntityCreatedEvent.class).param(EntityIdParam, "EntityIdParam").instanceOf(String.class).notNull().done();
            checker.check(EntityCreatedEvent.class).param(EntityRefParam, "EntityRefParam").instanceOf(EntityRef.class).notNull().done();
        }
    }

    class EntityDeletedEventSanityChecker
    extends DeclarativeSanityChecker
    {
        @Override
        protected void setup(SanityCheckerRuleBuilder checker)
        {
            checker.check(EntityCreatedEvent.class).param(EntityIdParam, "EntityIdParam").instanceOf(String.class).notNull().done();
            checker.check(EntityCreatedEvent.class).param(EntityRefParam, "EntityRefParam").instanceOf(EntityRef.class).notNull().done();
        }
    }

    class EntityDeletingEventSanityChecker
    extends DeclarativeSanityChecker
    {
        @Override
        protected void setup(SanityCheckerRuleBuilder checker)
        {
            checker.check(EntityCreatedEvent.class).param(EntityIdParam, "EntityIdParam").instanceOf(String.class).notNull().done();
            checker.check(EntityCreatedEvent.class).param(EntityRefParam, "EntityRefParam").instanceOf(EntityRef.class).notNull().done();
        }
    }
}

{'fraction_non_alphanumeric': 0.11284259984338293, 'fraction_numerical': 0.00274079874706343, 'mean_word_length': 3.1064308681672026, 'pattern_counts': {'":': 0, '<': 137, '<?xml version=': 0, '>': 137, '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': '5530505', 'n_tokens_mistral': 3555, 'n_tokens_neox': 3562, 'n_words': 777}