package com.proofpoint.sample;

import com.google.common.collect.MapMaker;
import com.google.inject.Inject;

import java.util.Collection;
import java.util.Map;
import java.util.concurrent.TimeUnit;

public class PersonStore
{
    private final Map<String, Person> persons;

    @Inject
    public PersonStore(StoreConfig config)
    {
        persons = new MapMaker()
                .expiration((long) config.getTtl().toMillis(), TimeUnit.MILLISECONDS)
                .makeMap();
    }

    public Person get(String id)
    {
        return persons.get(id);
    }

    public void put(String id, Person person)
    {
        persons.put(id, person);
    }

    public void delete(String id)
    {
        persons.remove(id);
    }

    public Collection<Person> getAll()
    {
        return persons.values();
    }
}

@@ -25,16 +25,61 @@
 ample;%0A%0A
+import com.google.common.base.Preconditions;%0A
 import c
@@ -113,16 +113,16 @@
 pMaker;%0A
-
 import c
@@ -365,32 +365,104 @@
 g config)%0A    %7B%0A
+        Preconditions.checkNotNull(config, %22config must not be null%22);%0A%0A
         persons 
@@ -630,32 +630,96 @@
 tring id)%0A    %7B%0A
+        Preconditions.checkNotNull(id, %22id must not be null%22);%0A%0A
         return p
@@ -785,32 +785,167 @@
 n person)%0A    %7B%0A
+        Preconditions.checkNotNull(id, %22id must not be null%22);%0A        Preconditions.checkNotNull(person, %22person must not be null%22);%0A%0A
         persons.
@@ -994,38 +994,102 @@
 lete(String id)%0A
-
     %7B%0A
+        Preconditions.checkNotNull(id, %22id must not be null%22);%0A%0A
         persons.

add precondition checks