<commit_before>package com.kryptnostic.directory.v1.domain;

import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.kryptnostic.kodex.v1.constants.Names;

public class Domain {
    public static final String        PUBLICLY_LISTABLE_FIELD         = "publiclyListable";
    private static final String        DOMAIN_SHARING_POLICY_FIELD     = "domainSharingPolicy";
    private static final String        OPEN_REGISTRATION_ENABLED_FIELD = "openRegistrationEnabled";

    private static final boolean       CONFIRMATION_EMAIL_NOT_REQUIRED_DEFAULT = false;
    private static final boolean       CONFIRMATION_EMAIL_REQUIRED_DEFAULT     = true;
    private static final boolean       NOT_PUBLICLY_LISTABLE_DEFAULT           = true;
    private static final boolean       PUBLICLY_LISTABLE_DEFAULT               = true;
    private static final boolean       OPEN_REGISTRATION_ENABLED_DEFAULT       = true;

    private final UUID                id;
    private final String              name;
    private final AtomicInteger       size;                                                   // Total number of users
                                                                                               // in
                                                                                               // domain
    private final DomainSharingPolicy domainSharingPolicy;
    private final boolean             confirmationEmailRequired;
    private final AtomicBoolean       publiclyListable;
    private final Boolean             openRegistrationEnabled;

    @JsonCreator
    public Domain(
            @JsonProperty( Names.ID_FIELD ) UUID id,
            @JsonProperty( Names.DOMAIN_FIELD ) String name,
            @JsonProperty( Names.SIZE_FIELD ) int size,
            @JsonProperty( DOMAIN_SHARING_POLICY_FIELD ) DomainSharingPolicy domainSharingPolicy,
            @JsonProperty( Names.CONFIRMATION_FIELD ) Optional<Boolean> confirmationEmailRequired,
            @JsonProperty( Names.OPEN_REGISTRATION_ALLOWED ) Optional<Boolean> openRegistrationEnabled,
            @JsonProperty( PUBLICLY_LISTABLE_FIELD ) Optional<Boolean> publiclyListable ) {
        this.id = id;
        this.name = name;
        this.size = new AtomicInteger( size );
        this.domainSharingPolicy = domainSharingPolicy;
        this.openRegistrationEnabled = openRegistrationEnabled.or( CONFIRMATION_EMAIL_NOT_REQUIRED_DEFAULT );
        this.confirmationEmailRequired = confirmationEmailRequired.or( CONFIRMATION_EMAIL_NOT_REQUIRED_DEFAULT );
        this.publiclyListable = new AtomicBoolean( publiclyListable.or( PUBLICLY_LISTABLE_DEFAULT ) );
    }

    public Domain( UUID id, String name, int size ) {
        this( id, name, size,
                DomainSharingPolicy.AllDomains,
                Optional.of( CONFIRMATION_EMAIL_NOT_REQUIRED_DEFAULT ),
                Optional.of( OPEN_REGISTRATION_ENABLED_DEFAULT ),
                Optional.of( PUBLICLY_LISTABLE_DEFAULT ) );
    }

    public Domain( DomainBuilder domainBuilder ) {
        this.id = domainBuilder.id;
        this.name = domainBuilder.name;
        this.size = domainBuilder.size;
        this.domainSharingPolicy = domainBuilder.domainSharingPolicy;
        this.confirmationEmailRequired = domainBuilder.confirmationEmailRequired;
        this.openRegistrationEnabled = domainBuilder.openRegistrationRequired;
        this.publiclyListable = domainBuilder.publiclyListable;<commit_msg>I goofed<commit_after>package com.kryptnostic.directory.v1.domain;

import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.kryptnostic.kodex.v1.constants.Names;

public class Domain {
    public static final String        PUBLICLY_LISTABLE_FIELD         = "publiclyListable";
    private static final String        DOMAIN_SHARING_POLICY_FIELD     = "domainSharingPolicy";
    private static final String        OPEN_REGISTRATION_ENABLED_FIELD = "openRegistrationEnabled";

    private static final boolean       CONFIRMATION_EMAIL_NOT_REQUIRED_DEFAULT = false;
    private static final boolean       CONFIRMATION_EMAIL_REQUIRED_DEFAULT     = true;
    private static final boolean       NOT_PUBLICLY_LISTABLE_DEFAULT           = true;
    private static final boolean       PUBLICLY_LISTABLE_DEFAULT               = true;
    private static final boolean       OPEN_REGISTRATION_ENABLED_DEFAULT       = true;

    private final UUID                id;
    private final String              name;
    private final AtomicInteger       size;                                                   // Total number of users
                                                                                               // in
                                                                                               // domain
    private final DomainSharingPolicy domainSharingPolicy;
    private final boolean             confirmationEmailRequired;
    private final AtomicBoolean       publiclyListable;
    private final Boolean             openRegistrationEnabled;

    @JsonCreator
    public Domain(
            @JsonProperty( Names.ID_FIELD ) UUID id,
            @JsonProperty( Names.DOMAIN_FIELD ) String name,
            @JsonProperty( Names.SIZE_FIELD ) int size,
            @JsonProperty( DOMAIN_SHARING_POLICY_FIELD ) DomainSharingPolicy domainSharingPolicy,
            @JsonProperty( Names.CONFIRMATION_FIELD ) Optional<Boolean> confirmationEmailRequired,
            @JsonProperty( Names.OPEN_REGISTRATION_ALLOWED ) Optional<Boolean> openRegistrationEnabled,
            @JsonProperty( PUBLICLY_LISTABLE_FIELD ) Optional<Boolean> publiclyListable ) {
        this.id = id;
        this.name = name;
        this.size = new AtomicInteger( size );
        this.domainSharingPolicy = domainSharingPolicy;
        this.openRegistrationEnabled = openRegistrationEnabled.or( OPEN_REGISTRATION_ENABLED_DEFAULT );
        this.confirmationEmailRequired = confirmationEmailRequired.or( CONFIRMATION_EMAIL_NOT_REQUIRED_DEFAULT );
        this.publiclyListable = new AtomicBoolean( publiclyListable.or( PUBLICLY_LISTABLE_DEFAULT ) );
    }

    public Domain( UUID id, String name, int size ) {
        this( id, name, size,
                DomainSharingPolicy.AllDomains,
                Optional.of( CONFIRMATION_EMAIL_NOT_REQUIRED_DEFAULT ),
                Optional.of( OPEN_REGISTRATION_ENABLED_DEFAULT ),
                Optional.of( PUBLICLY_LISTABLE_DEFAULT ) );
    }

    public Domain( DomainBuilder domainBuilder ) {
        this.id = domainBuilder.id;
        this.name = domainBuilder.name;
        this.size = domainBuilder.size;
        this.domainSharingPolicy = domainBuilder.domainSharingPolicy;
        this.confirmationEmailRequired = domainBuilder.confirmationEmailRequired;
        this.openRegistrationEnabled = domainBuilder.openRegistrationRequired;
        this.publiclyListable = domainBuilder.publiclyListable;
{'fraction_non_alphanumeric': 0.05861291605887813, 'fraction_numerical': 0.0005304336294921098, 'mean_word_length': 2.481994459833795, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '676793', 'n_tokens_mistral': 1903, 'n_tokens_neox': 1850, 'n_words': 388}