public class IdToFileMap extends Object
This is essentially a thin wrapper around a supplied getter and putter method; in the PuffinPlot Swing application, these are supplied by a java.util.prefs.Preferences object, and the IdToFileMap is used to keep track of the last-used directory for various Open File dialogs.
Constructor and Description |
---|
IdToFileMap(UnaryOperator<String> getter,
BiConsumer<String,String> putter)
Creates a new IdToFileMap, which wwill store and retrieve mappings
using the supplied getter and putter.
|
Modifier and Type | Method and Description |
---|---|
File |
get(String identifier)
Return the directory associated with an identifier.
|
String |
getString(String identifier)
Return the directory associated with an identifier, as a string.
|
void |
put(String identifier,
File directory)
Set the directory associated with an identifier.
|
public IdToFileMap(UnaryOperator<String> getter, BiConsumer<String,String> putter)
getter
- a getter method which returns a value for a provided
key. For a non-existent key, it should return an empty string.putter
- a fuction which takes a key and a value, and stores
the value under the given key.public File get(String identifier)
identifier
- an identifierpublic String getString(String identifier)
identifier
- an identifierCopyright © 2022. All rights reserved.