@Test public void testPut() { PersonStore store = new PersonStore(new StoreConfig(), ticker); store.put("foo", createPerson("foo@example.com", "Mr Foo")); assertThat(store.get("foo")).isEqualTo(createPerson("foo@example.com", "Mr Foo")); assertThat(store.getAll()).hasSize(1); }
public boolean put(String id, Person person) { requireNonNull(id, "id must not be null"); requireNonNull(person, "person must not be null"); boolean added = persons.put(id, person) == null; if (added) { stats.personAdded(); } else { stats.personUpdated(); } return added; }
PersonStore { public boolean put(String id, Person person) { requireNonNull(id, "id must not be null"); requireNonNull(person, "person must not be null"); boolean added = persons.put(id, person) == null; if (added) { stats.personAdded(); } else { stats.personUpdated(); } return added; } }
PersonStore { public boolean put(String id, Person person) { requireNonNull(id, "id must not be null"); requireNonNull(person, "person must not be null"); boolean added = persons.put(id, person) == null; if (added) { stats.personAdded(); } else { stats.personUpdated(); } return added; } @Inject  PersonStore(StoreConfig config, Ticker ticker); }
PersonStore { public boolean put(String id, Person person) { requireNonNull(id, "id must not be null"); requireNonNull(person, "person must not be null"); boolean added = persons.put(id, person) == null; if (added) { stats.personAdded(); } else { stats.personUpdated(); } return added; } @Inject  PersonStore(StoreConfig config, Ticker ticker); @Flatten PersonStoreStats getStats(); Person get(String id); boolean put(String id, Person person); boolean delete(String id); Collection<StoreEntry> getAll(); }
PersonStore { public boolean put(String id, Person person) { requireNonNull(id, "id must not be null"); requireNonNull(person, "person must not be null"); boolean added = persons.put(id, person) == null; if (added) { stats.personAdded(); } else { stats.personUpdated(); } return added; } @Inject  PersonStore(StoreConfig config, Ticker ticker); @Flatten PersonStoreStats getStats(); Person get(String id); boolean put(String id, Person person); boolean delete(String id); Collection<StoreEntry> getAll();  }