class Builder implements CommandLatencyCollectorOptions.Builder {

        private TimeUnit targetUnit = DEFAULT_TARGET_UNIT;

        private double[] targetPercentiles = DEFAULT_TARGET_PERCENTILES;

        private boolean resetLatenciesAfterEvent = DEFAULT_RESET_LATENCIES_AFTER_EVENT;

        private boolean localDistinction = DEFAULT_LOCAL_DISTINCTION;

        private boolean enabled = DEFAULT_ENABLED;

        private boolean usePauseDetector = DEFAULT_USE_NO_PAUSE_DETECTOR;

        private Builder() {
        }

        /**
         * Disable the latency collector.
         *
         * @return this {@link Builder}.
         */
        @Override
        public Builder disable() {
            this.enabled = false;
            return this;
        }

        /**
         * Enable the latency collector.
         *
         * @return this {@link Builder}.
         * @since 5.1
         */
        @Override
        public Builder enable() {
            this.enabled = true;
            return this;
        }

        /**
         * Use {@code LatencyUtils.SimplePauseDetector} to detect pauses. Defaults to no pause detector.
         *
         * @return this {@link DefaultCommandLatencyCollectorOptions.Builder}.
         * @since 6.1.7
         * @see org.LatencyUtils.SimplePauseDetector
         */
        @Override
        public Builder usePauseDetector() {
            this.usePauseDetector = true;
            return this;
        }

        /**
         * Do not detect pauses. Defaults to no pause detector.
         *
         * @return this {@link DefaultCommandLatencyCollectorOptions.Builder}.
         * @since 6.1.7
         */
        @Override
        public Builder useNoPauseDetector() {
            this.usePauseDetector = false;
            return this;
        }

        /**
         * Set the target unit for the latencies. Defaults to {@link TimeUnit#MILLISECONDS}. See
         * {@link DefaultCommandLatencyCollectorOptions#DEFAULT_TARGET_UNIT}.
         *
         * @param targetUnit the target unit, must not be {@code null}
         * @return this {@link Builder}.
         */
        @Override
        public Builder targetUnit(TimeUnit targetUnit) {
            LettuceAssert.notNull(targetUnit, "TargetUnit must not be null");
            this.targetUnit = targetUnit;
            return this;
        }

        /**
         * Sets the emitted percentiles. Defaults to 50.0, 90.0, 95.0, 99.0, 99.9} . See
         * {@link DefaultCommandLatencyCollectorOptions#DEFAULT_TARGET_PERCENTILES}.
         *
         * @param targetPercentiles the percentiles which should be emitted, must not be {@code null}
         * @return this {@link Builder}.
         */
        @Override
        public Builder targetPercentiles(double[] targetPercentiles) {
            LettuceAssert.notNull(targetPercentiles, "TargetPercentiles must not be null");
            this.targetPercentiles = targetPercentiles;
            return this;
        }

        /**
         * Sets whether the recorded latencies should be reset once the metrics event was emitted. Defaults to {@code true}.
         * See {@link DefaultCommandLatencyCollectorOptions#DEFAULT_RESET_LATENCIES_AFTER_EVENT}.
         *
         * @param resetLatenciesAfterEvent {@code true} if the recorded latencies should be reset once the metrics event was
         *        emitted
         * @return this {@link Builder}.
         */
        @Override
        public Builder resetLatenciesAfterEvent(boolean resetLatenciesAfterEvent) {
            this.resetLatenciesAfterEvent = resetLatenciesAfterEvent;
            return this;
        }

        /**
         * Enables per connection metrics tracking insead of per host/port. If {@code true}, multiple connections to the same
         * host/connection point will be recorded separately which allows to inspect every connection individually. If
         * {@code false}, multiple connections to the same host/connection point will be recorded together. This allows a
         * consolidated view on one particular service. Defaults to {@code false}. See
         * {@link DefaultCommandLatencyCollectorOptions#DEFAULT_LOCAL_DISTINCTION}.
         *
         * @param localDistinction {@code true} if latencies are recorded distinct on local level (per connection)
         * @return this {@link Builder}.
         */
        @Override
        public Builder localDistinction(boolean localDistinction) {
            this.localDistinction = localDistinction;
            return this;
        }

        /**
         * @return a new instance of {@link DefaultCommandLatencyCollectorOptions}.
         */
        @Override
        public DefaultCommandLatencyCollectorOptions build() {
            return new DefaultCommandLatencyCollectorOptions(this);
        }

    }

    @Override
    public TimeUnit targetUnit() {
        return targetUnit;
    }

    @Override
    public double[] targetPercentiles() {<FILL_FUNCTION_BODY>

        double[] result = new double[targetPercentiles.length];
        System.arraycopy(targetPercentiles, 0, result, 0, targetPercentiles.length);
        return result;
    
<no_super_class>