<commit_before>package org.devnull.security.model

import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString
import javax.persistence.CascadeType
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
import javax.persistence.JoinColumn
import javax.persistence.JoinTable
import javax.persistence.ManyToMany
import javax.persistence.Table
import org.slf4j.LoggerFactory
import org.springframework.security.core.GrantedAuthority
import org.springframework.security.core.authority.SimpleGrantedAuthority
import org.springframework.security.core.userdetails.UserDetails
import javax.persistence.FetchType
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.constraints.NotNull
import org.hibernate.annotations.Index
import javax.persistence.UniqueConstraint

@Entity
@Table(name = "SecurityUser", uniqueConstraints = [
    @UniqueConstraint(columnNames=["openId"])
])
@EqualsAndHashCode(excludes = "roles")
@ToString(excludes = "roles", includeNames = true)
class User implements Serializable, UserDetails {

    static final def log = LoggerFactory.getLogger(User)
    static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    Integer id

    @ManyToMany(cascade = [CascadeType.MERGE, CascadeType.PERSIST], fetch=FetchType.EAGER)
    @JoinTable(
    name = "SecurityUserRole",
    joinColumns = @JoinColumn(name = "UserId"),
    inverseJoinColumns = @JoinColumn(name = "RoleId")
    )
    List<Role> roles = []

    String openId


    @Pattern(regexp=".{1,50}\\@.{1,100}", message="Email must be properly formatted")
    String email

    @Size(min=2)
    String firstName

    @Size(min=2)
    String lastName

    @NotNull
    Boolean enabled = true

    /**
     * Immutable once set
     * @param id
     */
    void setId(Long id) {
        if (this.id) {<commit_msg>better validation error message<commit_after>package org.devnull.security.model

import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString
import javax.persistence.CascadeType
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
import javax.persistence.JoinColumn
import javax.persistence.JoinTable
import javax.persistence.ManyToMany
import javax.persistence.Table
import org.slf4j.LoggerFactory
import org.springframework.security.core.GrantedAuthority
import org.springframework.security.core.authority.SimpleGrantedAuthority
import org.springframework.security.core.userdetails.UserDetails
import javax.persistence.FetchType
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.constraints.NotNull
import org.hibernate.annotations.Index
import javax.persistence.UniqueConstraint

@Entity
@Table(name = "SecurityUser", uniqueConstraints = [
    @UniqueConstraint(columnNames=["openId"])
])
@EqualsAndHashCode(excludes = "roles")
@ToString(excludes = "roles", includeNames = true)
class User implements Serializable, UserDetails {

    static final def log = LoggerFactory.getLogger(User)
    static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    Integer id

    @ManyToMany(cascade = [CascadeType.MERGE, CascadeType.PERSIST], fetch=FetchType.EAGER)
    @JoinTable(
    name = "SecurityUserRole",
    joinColumns = @JoinColumn(name = "UserId"),
    inverseJoinColumns = @JoinColumn(name = "RoleId")
    )
    List<Role> roles = []

    String openId


    @Pattern(regexp=".{1,50}\\@.{1,100}", message="Email must be properly formatted")
    String email

    @Size(min=1, message="First name cannot be empty")
    String firstName

    @Size(min=1, message="Last name cannot be empty")
    String lastName

    @NotNull
    Boolean enabled = true

    /**
     * Immutable once set
     * @param id
     */
    void setId(Long id) {
        if (this.id) {
{'fraction_non_alphanumeric': 0.0966231205324131, 'fraction_numerical': 0.005422726152329307, 'mean_word_length': 4.747875354107649, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '259844', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1141, 'n_words': 255}