<commit_before>package com.autonomy.frontend.configuration;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

/*
 * $Id:$
 *
 * Copyright (c) 2014, Autonomy Systems Ltd.
 *
 * Last modified by $Author:$ on $Date:$
 */
@Data
@JsonDeserialize(builder = SingleUserAuthentication.Builder.class)
public class SingleUserAuthentication implements Authentication<SingleUserAuthentication> {

    private final DefaultLogin defaultLogin;
    private final BCryptUsernameAndPassword singleUser;
    private final String method;

    private SingleUserAuthentication(final Builder builder) {
        this.defaultLogin = builder.defaultLogin;
        this.singleUser = builder.singleUser;
        this.method = builder.method;
    }

    @Override
    public String getMethod() {
        return method;
    }

    @Override
    public UsernameAndPassword getDefaultLogin() {
        return defaultLogin.getDefaultLogin();
    }

    @Override
    public SingleUserAuthentication generateDefaultLogin() {
        final Builder builder = new Builder(this);

        builder.defaultLogin = DefaultLogin.generateDefaultLogin();

        return this;
    }

    @Override
    public SingleUserAuthentication withoutDefaultLogin() {
        final Builder builder = new Builder(this);

        builder.defaultLogin = null;

        return this;
    }

    @Override
    public SingleUserAuthentication withHashedPasswords() {
        final Builder builder = new Builder(this);

        builder.singleUser = singleUser.withHashedPassword();

        return this;
    }

    @Override
    public SingleUserAuthentication withoutPasswords() {
        final Builder builder = new Builder(this);

        builder.singleUser = singleUser.withoutPasswords();

        return this;
    }

    @Override
    public SingleUserAuthentication merge(final Authentication<?> other) {
        if(other instanceof SingleUserAuthentication) {
            final SingleUserAuthentication castOther = (SingleUserAuthentication) other;

            final Builder builder = new Builder(this);

            builder.setDefaultLogin(this.defaultLogin == null ? castOther.defaultLogin : this.defaultLogin.merge(castOther.defaultLogin));
            builder.setSingleUser(this.singleUser == null ? castOther.singleUser : this.singleUser.merge(castOther.singleUser));
            builder.setMethod(this.method == null ? castOther.method : this.method);

            return builder.build();
        }
        else {
            return this;
        }
    }

    @Override
    public void basicValidate() throws ConfigException {
        if(LoginTypes.SINGLE_USER.equalsIgnoreCase(method)) {
            singleUser.basicValidate();
        }
    }

    @Override
    public boolean isEnabled() {
        return true;<commit_msg>[configuration] (FOSS-59) Return builder.build(), not this /facepalm. [rev: matthew.gordon2]<commit_after>package com.autonomy.frontend.configuration;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

/*
 * $Id:$
 *
 * Copyright (c) 2014, Autonomy Systems Ltd.
 *
 * Last modified by $Author:$ on $Date:$
 */
@Data
@JsonDeserialize(builder = SingleUserAuthentication.Builder.class)
public class SingleUserAuthentication implements Authentication<SingleUserAuthentication> {

    private final DefaultLogin defaultLogin;
    private final BCryptUsernameAndPassword singleUser;
    private final String method;

    private SingleUserAuthentication(final Builder builder) {
        this.defaultLogin = builder.defaultLogin;
        this.singleUser = builder.singleUser;
        this.method = builder.method;
    }

    @Override
    public String getMethod() {
        return method;
    }

    @Override
    public UsernameAndPassword getDefaultLogin() {
        return defaultLogin.getDefaultLogin();
    }

    @Override
    public SingleUserAuthentication generateDefaultLogin() {
        final Builder builder = new Builder(this);

        builder.defaultLogin = DefaultLogin.generateDefaultLogin();

        return builder.build();
    }

    @Override
    public SingleUserAuthentication withoutDefaultLogin() {
        final Builder builder = new Builder(this);

        builder.defaultLogin = null;

        return builder.build();
    }

    @Override
    public SingleUserAuthentication withHashedPasswords() {
        final Builder builder = new Builder(this);

        builder.singleUser = singleUser.withHashedPassword();

        return builder.build();
    }

    @Override
    public SingleUserAuthentication withoutPasswords() {
        final Builder builder = new Builder(this);

        builder.singleUser = singleUser.withoutPasswords();

        return builder.build();
    }

    @Override
    public SingleUserAuthentication merge(final Authentication<?> other) {
        if(other instanceof SingleUserAuthentication) {
            final SingleUserAuthentication castOther = (SingleUserAuthentication) other;

            final Builder builder = new Builder(this);

            builder.setDefaultLogin(this.defaultLogin == null ? castOther.defaultLogin : this.defaultLogin.merge(castOther.defaultLogin));
            builder.setSingleUser(this.singleUser == null ? castOther.singleUser : this.singleUser.merge(castOther.singleUser));
            builder.setMethod(this.method == null ? castOther.method : this.method);

            return builder.build();
        }
        else {
            return this;
        }
    }

    @Override
    public void basicValidate() throws ConfigException {
        if(LoginTypes.SINGLE_USER.equalsIgnoreCase(method)) {
            singleUser.basicValidate();
        }
    }

    @Override
    public boolean isEnabled() {
        return true;
{'fraction_non_alphanumeric': 0.08501371188901435, 'fraction_numerical': 0.0017744797547991611, 'mean_word_length': 3.189189189189189, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '6544246', 'n_tokens_mistral': 1583, 'n_tokens_neox': 1502, 'n_words': 353}