package com.proofpoint.sample;

import com.proofpoint.configuration.Config;
import com.proofpoint.configuration.DeprecatedConfig;
import com.proofpoint.stats.Duration;

import javax.validation.constraints.NotNull;
import java.util.concurrent.TimeUnit;

public class StoreConfig
{
    private Duration ttl = new Duration(1, TimeUnit.HOURS);

    @Deprecated
    @DeprecatedConfig("store.ttl-in-ms")
    public StoreConfig setTtlInMs(int duration)
    {
        return setTtl(new Duration(duration, TimeUnit.MILLISECONDS));
    }

    @Config("store.ttl")
    public StoreConfig setTtl(Duration ttl)
    {
        this.ttl = ttl;
        return this;
    }

    @NotNull
    public Duration getTtl()
    {
        return ttl;
    }
}

@@ -25,16 +25,61 @@
 ample;%0A%0A
+import com.google.common.base.Preconditions;%0A
 import c
@@ -634,32 +634,234 @@
 tion ttl)%0A    %7B%0A
+        Preconditions.checkNotNull(ttl, %22ttl must not be null%22); // TODO: remove once configuration supports bean validation%0A        Preconditions.checkArgument(ttl.toMillis() %3E 0, %22ttl must be %3E 0%22);%0A%0A
         this.ttl

add preconditions