Repository: netty/netty
File: pkitesting/src/main/java/io/netty/pkitesting/CertificateBuilder.java (Java)

Code before:
    public CertificateBuilder copy() {
        CertificateBuilder copy = new CertificateBuilder();
        copy.random = random;
        copy.algorithm = algorithm;
        copy.notBefore = notBefore;
        copy.notAfter = notAfter;
        copy.modifierCallbacks = new ArrayList<>(modifierCallbacks);
        copy.subjectAlternativeNames = new ArrayList<>(subjectAlternativeNames);
        copy.crlDistributionPoints = new ArrayList<>(crlDistributionPoints);
        copy.serial = serial;
        copy.subject = subject;
        copy.isCertificateAuthority = isCertificateAuthority;
        copy.pathLengthConstraint = pathLengthConstraint;
        copy.publicKey = publicKey;
        copy.keyUsage = keyUsage;
        copy.extendedKeyUsage = new TreeSet<>(extendedKeyUsage);
        return copy;
    }

    /**
     * Set the {@link Provider} instance to use when generating keys.
     * @param provider The provider instance to use.
     * @return This certificate builder.
     */
    public CertificateBuilder provider(Provider provider) {
        this.provider = requireNonNull(provider);
        return this;
    }

    /**
     * Set the {@link SecureRandom} instance to use when generating keys.
     * @param secureRandom The secure random instance to use.
     * @return This certificate builder.
     */
    public CertificateBuilder secureRandom(SecureRandom secureRandom) {
        random = requireNonNull(secureRandom);
        return this;
    }

    /**
     * Set the not-before field of the certificate. The certificate will not be valid before this time.
     * @param instant The not-before time.
     * @return This certificate builder.
     */
    public CertificateBuilder notBefore(Instant instant) {
        notBefore = requireNonNull(instant);
        return this;
    }

    /**
     * Set the not-after field of the certificate. The certificate will not be valid after this time.

Review comment (suggestion):
We could permit null here, so the setting is reversible.

Code after:
    public CertificateBuilder copy() {
        CertificateBuilder copy = new CertificateBuilder();
        copy.random = random;
        copy.algorithm = algorithm;
        copy.notBefore = notBefore;
        copy.notAfter = notAfter;
        copy.modifierCallbacks = new ArrayList<>(modifierCallbacks);
        copy.subjectAlternativeNames = new ArrayList<>(subjectAlternativeNames);
        copy.crlDistributionPoints = new ArrayList<>(crlDistributionPoints);
        copy.serial = serial;
        copy.subject = subject;
        copy.isCertificateAuthority = isCertificateAuthority;
        copy.pathLengthConstraint = pathLengthConstraint;
        copy.publicKey = publicKey;
        copy.keyUsage = keyUsage;
        copy.extendedKeyUsage = new TreeSet<>(extendedKeyUsage);
        copy.provider = provider;
        return copy;
    }

    /**
     * Set the {@link Provider} instance to use when generating keys.
     * @param provider The provider instance to use.
     * @return This certificate builder.
     */
    public CertificateBuilder provider(Provider provider) {
        this.provider = provider;
        return this;
    }

    /**
     * Set the {@link SecureRandom} instance to use when generating keys.
     * @param secureRandom The secure random instance to use.
     * @return This certificate builder.
     */
    public CertificateBuilder secureRandom(SecureRandom secureRandom) {
        random = requireNonNull(secureRandom);
        return this;
    }

    /**
     * Set the not-before field of the certificate. The certificate will not be valid before this time.
     * @param instant The not-before time.
     * @return This certificate builder.
     */
    public CertificateBuilder notBefore(Instant instant) {
        notBefore = requireNonNull(instant);
        return this;
    }

    /**