public class InMemoryCounterService extends java.lang.Object implements CounterService
Constructor and Description |
---|
InMemoryCounterService(InMemoryCounterRepository counterRepository) |
Modifier and Type | Method and Description |
---|---|
void |
decrement(java.lang.String name)
Decrement the counter by one
|
Counter |
getOrCreate(java.lang.String name)
Returns an existing counter for the given name or creates a new counter set to zero
|
void |
increment(java.lang.String name)
Increment the counter by one
|
void |
reset(java.lang.String name)
Reset the counter to zero
|
public InMemoryCounterService(InMemoryCounterRepository counterRepository)
public Counter getOrCreate(java.lang.String name)
CounterService
getOrCreate
in interface CounterService
name
- name of the counterpublic void increment(java.lang.String name)
CounterService
increment
in interface CounterService
name
- the counter namepublic void decrement(java.lang.String name)
CounterService
decrement
in interface CounterService
name
- the counter namepublic void reset(java.lang.String name)
CounterService
reset
in interface CounterService
name
- the counter name