package io.praesid.livestats;

import lombok.ToString;

import java.time.Duration;

@ToString
public class DecayConfig {

    public static final DecayConfig NEVER = new DecayConfig(1, Duration.ofNanos(0)) {
        @Override
        public String toString() {
            return "NEVER";
        }
    };

    public final double multiplier;
    public final long period;

    public DecayConfig(final double multiplier, final Duration period) {
        this.multiplier = multiplier;
        this.period = period.toNanos();
    }
}

@@ -24,16 +24,61 @@
 stats;%0A%0A
+import com.google.common.base.Preconditions;%0A
 import l
@@ -224,30 +224,8 @@
 fig(
-1, Duration.ofNanos(0)
 ) %7B%0A
@@ -475,76 +475,493 @@
     
-this.multiplier = multiplier;%0A        this.period = period.toNanos()
+Preconditions.checkArgument(multiplier %3E= 0, %22Multiplier must be %3E= 0%22);%0A        Preconditions.checkArgument(multiplier %3C 1, %22Multiplier must be %3C 1%22);%0A        Preconditions.checkNotNull(period, %22Period must be specified%22);%0A        Preconditions.checkArgument(!period.isNegative() && !period.isZero(), %22Period must be positive%22);%0A        this.multiplier = multiplier;%0A        this.period = period.toNanos();%0A    %7D%0A%0A    private DecayConfig() %7B%0A        multiplier = 1;%0A        period = 0
 ;%0A  

Enforce the validity of DecayConfig args