<commit_before>/*
 * SportChef – Sports Competition Management Software
 * Copyright (C) 2016 <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package ch.sportchef.business.user.entity;

public class UserBuilder {
    private Long userId;
    private String firstName;
    private String lastName;
    private String phone;
    private String email;

    private UserBuilder() {
    }

    public static UserBuilder anUser() {
        return new UserBuilder();
    }

    public static UserBuilder fromUser(final User user) {
        return anUser()
                .withUserId(user.getUserId())
                .withFirstName(user.getFirstName())
                .withLastName(user.getLastName())
                .withPhone(user.getPhone())
                .withEmail(user.getEmail());
    }

    public UserBuilder withUserId(Long userId) {
        this.userId = userId;
        return this;
    }

    public UserBuilder withFirstName(String firstName) {
        this.firstName = firstName;
        return this;
    }

    public UserBuilder withLastName(String lastName) {
        this.lastName = lastName;
        return this;
    }

    public UserBuilder withPhone(String phone) {
        this.phone = phone;
        return this;
    }

    public UserBuilder withEmail(String email) {
        this.email = email;
        return this;
    }

    public UserBuilder but() {
        return anUser().withUserId(userId).withFirstName(firstName).withLastName(lastName).withPhone(phone).withEmail(email);
    }

    public User build() {
        User user = new User(userId, firstName, lastName, phone, email);
        return user;
    }
}<commit_msg>#209 Add version support to UserBuilder<commit_after>/*
 * SportChef – Sports Competition Management Software
 * Copyright (C) 2016 <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package ch.sportchef.business.user.entity;

public class UserBuilder {
    private Long userId;
    private String firstName;
    private String lastName;
    private String phone;
    private String email;
    private Long version = 0L;

    private UserBuilder() {
    }

    public static UserBuilder anUser() {
        return new UserBuilder();
    }

    public static UserBuilder fromUser(final User user) {
        return anUser()
                .withUserId(user.getUserId())
                .withFirstName(user.getFirstName())
                .withLastName(user.getLastName())
                .withPhone(user.getPhone())
                .withEmail(user.getEmail());
    }

    public UserBuilder withUserId(Long userId) {
        this.userId = userId;
        return this;
    }

    public UserBuilder withFirstName(String firstName) {
        this.firstName = firstName;
        return this;
    }

    public UserBuilder withLastName(String lastName) {
        this.lastName = lastName;
        return this;
    }

    public UserBuilder withPhone(String phone) {
        this.phone = phone;
        return this;
    }

    public UserBuilder withEmail(String email) {
        this.email = email;
        return this;
    }

    public UserBuilder withVersion(Long version) {
        this.version = version;
        return this;
    }

    public UserBuilder but() {
        return anUser().withUserId(userId).withFirstName(firstName).withLastName(lastName).withPhone(phone).withEmail(email);
    }

    public User build() {
        return new User(userId, firstName, lastName, phone, email, version);
    }
}
{'fraction_non_alphanumeric': 0.08052553507098961, 'fraction_numerical': 0.0029667302394575123, 'mean_word_length': 2.6674436674436675, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7249358', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1228, 'n_words': 441}