|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.appenginefan.toolkit.persistence.MapBasedPersistence<T>
public class MapBasedPersistence<T>
A simple, map-based store that holds data in memory. Should only be used for unit tests, mostly for two reasons. First of all, this persistence does not do any defensive copies of its content, so nasty side effects can occur. Second, since all is in memory, nothing is really getting persisted beyond the lifetime of the virtual machine.
| Constructor Summary | |
|---|---|
MapBasedPersistence()
|
|
| Method Summary | ||
|---|---|---|
T |
get(String key)
Gets an entry from the store. |
|
List<String> |
keyScan(String start,
String end,
int max)
Finds zero or more entries that are within a given range. |
|
List<String> |
keyScanReverse(String start,
String end,
int max)
Finds zero or more entries that are within a given range, but orders in the opposite direction. |
|
T |
mutate(String key,
Function<? super T,? extends T> mutator)
Modifies an entry in the store. |
|
static
|
newInstance()
Factory method |
|
List<Map.Entry<String,T>> |
scan(String start,
String end,
int max)
Finds zero or more entries that are within a given range |
|
List<Map.Entry<String,T>> |
scanReverse(String start,
String end,
int max)
Finds zero or more entries that are within a given range, but orders in the opposite direction. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MapBasedPersistence()
| Method Detail |
|---|
public static <T> MapBasedPersistence<T> newInstance()
public T get(String key)
Persistence
get in interface Persistence<T>key - the key to look up the data from
public T mutate(String key,
Function<? super T,? extends T> mutator)
Persistence
mutate in interface Persistence<T>key - the key to modifymutator - a function that applies a change to the data
and stores the new result. If the data does
not exist in the store yet, null will be
passed in. If the data should be deleted from
the store, the function will return null.
public List<Map.Entry<String,T>> scan(String start,
String end,
int max)
Persistence
scan in interface Persistence<T>start - a lower bound of the range of keys to look in
(inclusive)end - an upper bound of the range of keys to look in
(exclusive)max - a maximum amount of elements to return. The
implementation of the store may choose to
return less (for example, if a store can only
fetch 10 elements per query, then setting a
max of 1000 will still only return 10), but
never more.
public List<Map.Entry<String,T>> scanReverse(String start,
String end,
int max)
Persistence
scanReverse in interface Persistence<T>start - a lower bound of the range of keys to look in
(inclusive)end - an upper bound of the range of keys to look in
(exclusive)max - a maximum amount of elements to return. The
implementation of the store may choose to
return less (for example, if a store can only
fetch 10 elements per query, then setting a
max of 1000 will still only return 10), but
never more.
public List<String> keyScan(String start,
String end,
int max)
Persistence
keyScan in interface Persistence<T>start - a lower bound of the range of keys to look in
(inclusive)end - an upper bound of the range of keys to look in
(exclusive)max - a maximum amount of elements to return. The
implementation of the store may choose to
return less (for example, if a store can only
fetch 10 elements per query, then setting a
max of 1000 will still only return 10), but
never more.
public List<String> keyScanReverse(String start,
String end,
int max)
Persistence
keyScanReverse in interface Persistence<T>start - a lower bound of the range of keys to look in
(inclusive)end - an upper bound of the range of keys to look in
(exclusive)max - a maximum amount of elements to return. The
implementation of the store may choose to
return less (for example, if a store can only
fetch 10 elements per query, then setting a
max of 1000 will still only return 10), but
never more.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||