<commit_before>package org.synyx.minos.skillz.domain;

import static org.hibernate.annotations.CascadeType.*;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.OneToMany;

import org.hibernate.annotations.Cascade;
import org.synyx.hades.domain.auditing.AbstractAuditable;
import org.synyx.minos.core.domain.User;
import org.synyx.minos.util.Assert;


/**
 * Categories group {@link Skill}s together.
 * 
 * @author <NAME> - <EMAIL>
 */
@Entity
public class Category extends AbstractAuditable<User, Long> {

    private static final long serialVersionUID = 1447239273288778108L;

    private String name;
    private String description;

    @OneToMany
    @Cascade( { PERSIST })
    private final List<Skill> skills = new ArrayList<Skill>();


    protected Category() {

    }


    /**
     * Creates a new {@link Category} with the given name and no description.
     * 
     * @param string
     */
    public Category(String name) {

        this(name, null);
    }


    /**
     * Creates a new {@link Category} with the given name and description.
     * 
     * @param name
     * @param description
     */
    public Category(String name, String description) {

        this.name = name;
        this.description = description;
    }


    /**
     * Returns the name.
     * 
     * @return the name
     */
    public String getName() {

        return name;
    }


    /**
     * Sets the name.
     * 
     * @param name the name to set
     */
    public void setName(String name) {

        this.name = name;
    }


    /**
     * Returns the description.
     * 
     * @return the description
     */
    public String getDescription() {

        return description;
    }


    /**
     * Sets the description.
     * 
     * @param description the description to set
     */
    public void setDescription(String description) {

        this.description = description;
    }


    /**
     * Adds the given {@link Skill} to the category. Assigns the category to the skill if not already assigned.
     * 
     * @param skill
     * @return
     */
    public Category add(Skill skill) {

        this.skills.add(skill);

        if (!skill.has(this)) {
            skill.setCategory(this);
        }

        return this;
    }


    /**
     * Returns the skills of that {@link Category}.
     * 
     * @return the skills
     */
    public List<Skill> getSkillz() {

        return skills;
    }


    /**
     * Assigns the given {@link Skill}s to the category.
     * 
     * @param skills the skills to set
     */
    public void setSkills(Collection<Skill> skills) {

        Assert.notNull(skills);

        for (Skill skill : skills) {
            add(skill);
        }
    }


    /**
     * Returns whether the given skill is assigned to the {@link Category}.
     * 
     * @param skill
     * @return
     */
    public boolean has(Skill skill) {

        return this.skills.contains(skill);
    }


    void remove(Skill skill) {

        this.skills.remove(skill);
    }


    /*
     * (non-Javadoc)
     * 
     * @see org.synyx.hades.domain.support.AbstractPersistable#toString()
     */
    @Override
    public String toString() {

        StringBuilder builder = new StringBuilder(getName());
        builder.append(": ");

        for (Skill skill : skills) {
            builder.append(skill.getName());
            builder.append(", ");
        }

        return builder.substring(0, builder.length() - 2).toString();
    }
}
<commit_msg>* fixed mapping annotation for List<Skill> at Category - fixes #390<commit_after>package org.synyx.minos.skillz.domain;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.OneToMany;

import org.synyx.hades.domain.auditing.AbstractAuditable;
import org.synyx.minos.core.domain.User;
import org.synyx.minos.util.Assert;


/**
 * Categories group {@link Skill}s together.
 * 
 * @author <NAME> - <EMAIL>
 * @author <NAME> - <EMAIL>
 */
@Entity
public class Category extends AbstractAuditable<User, Long> {

    private static final long serialVersionUID = 1447239273288778108L;

    private String name;
    private String description;

    @OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, mappedBy = "category")
    private final List<Skill> skills = new ArrayList<Skill>();


    protected Category() {

    }


    /**
     * Creates a new {@link Category} with the given name and no description.
     * 
     * @param string
     */
    public Category(String name) {

        this(name, null);
    }


    /**
     * Creates a new {@link Category} with the given name and description.
     * 
     * @param name
     * @param description
     */
    public Category(String name, String description) {

        this.name = name;
        this.description = description;
    }


    /**
     * Returns the name.
     * 
     * @return the name
     */
    public String getName() {

        return name;
    }


    /**
     * Sets the name.
     * 
     * @param name the name to set
     */
    public void setName(String name) {

        this.name = name;
    }


    /**
     * Returns the description.
     * 
     * @return the description
     */
    public String getDescription() {

        return description;
    }


    /**
     * Sets the description.
     * 
     * @param description the description to set
     */
    public void setDescription(String description) {

        this.description = description;
    }


    /**
     * Adds the given {@link Skill} to the category. Assigns the category to the skill if not already assigned.
     * 
     * @param skill
     * @return
     */
    public Category add(Skill skill) {

        this.skills.add(skill);

        if (!skill.has(this)) {
            skill.setCategory(this);
        }

        return this;
    }


    /**
     * Returns the skills of that {@link Category}.
     * 
     * @return the skills
     */
    public List<Skill> getSkillz() {

        return skills;
    }


    /**
     * Assigns the given {@link Skill}s to the category.
     * 
     * @param skills the skills to set
     */
    public void setSkills(Collection<Skill> skills) {

        Assert.notNull(skills);

        for (Skill skill : skills) {
            add(skill);
        }
    }


    /**
     * Returns whether the given skill is assigned to the {@link Category}.
     * 
     * @param skill
     * @return
     */
    public boolean has(Skill skill) {

        return this.skills.contains(skill);
    }


    void remove(Skill skill) {

        this.skills.remove(skill);
    }


    /*
     * (non-Javadoc)
     * 
     * @see org.synyx.hades.domain.support.AbstractPersistable#toString()
     */
    @Override
    public String toString() {

        StringBuilder builder = new StringBuilder(getName());
        builder.append(": ");

        for (Skill skill : skills) {
            builder.append(skill.getName());
            builder.append(", ");
        }

        return builder.substring(0, builder.length() - 2).toString();
    }
}

{'fraction_non_alphanumeric': 0.11157253599114064, 'fraction_numerical': 0.006229235880398671, 'mean_word_length': 2.0280804694048618, 'pattern_counts': {'":': 2, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3229909', 'n_tokens_mistral': 2219, 'n_tokens_neox': 2078, 'n_words': 555}