T
- The type to associate with a specific path.public class FileSystemMap<T> extends Object
This class is thread safe in its public methods: concurrent calls to the trie will have the exclusiveness in write/remove operations, while allowing parallel reads to the whole data structure: an attempt could be made to make the trie more concurrent by locking branches of the trie instead of the whole object, although that will require some thought around how to grant parallel writes.
Modifier and Type | Class and Description |
---|---|
static interface |
FileSystemMap.ValueLoader<T>
Wrapper class that implements a method for loading a value in the leaves of the trie.
|
Constructor and Description |
---|
FileSystemMap(FileSystemMap.ValueLoader<T> loader,
ProjectFilesystem filesystem) |
Modifier and Type | Method and Description |
---|---|
com.google.common.collect.ImmutableMap<Path,T> |
asMap()
Returns a copy of the leaves stored in the trie as a map.
|
T |
get(Path path)
Gets the value associated with the given path.
|
T |
getIfPresent(Path path)
Gets the value associated with the given path, if found, or `null` otherwise.
|
void |
put(Path path,
T value)
Puts a path and a value into the map.
|
void |
remove(Path path)
Removes the given path.
|
void |
removeAll()
Empties the trie leaving only the root node available.
|
public FileSystemMap(FileSystemMap.ValueLoader<T> loader, ProjectFilesystem filesystem)
public void put(Path path, T value)
path
- The path to store.value
- The value to associate to the given path.public void remove(Path path)
Removing a path involves the following:
path
- The path specifying the branch to remove.public void removeAll()
public T get(Path path)
path
- The path to fetch.@Nullable public T getIfPresent(Path path)
path
- The path to fetch.