Package io.ocfl.core.model
Class PathBiMap
java.lang.Object
io.ocfl.core.model.PathBiMap
BiDirection map implementation that focuses on OCFL structures. FileIds are digest values and are case insensitive.
A single fileId can map to many paths, but a single path can only map to one fileId.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsFileId
(String fileId) Indicates if the specified fileId is in the mapboolean
containsPath
(String path) Indicates if the specified path is in the mapboolean
static PathBiMap
fromFileIdMap
(Map<String, Set<String>> map) Constructs a new PathBiMap from an existing map of fileIds to paths.Returns the fileId associated to the path or nullReturns an immutable view of the PathBiMap, mapping fileIds to paths.Returns all of the paths associated to the fileId, or an empty set.Returns an immutable view of the PathBiMap, mapping paths to fileIdsint
hashCode()
void
Adds a new fileId => path mappingremoveFileId
(String fileId) Removes a fileId from the map.removePath
(String path) Removes the path from the map.toString()
-
Constructor Details
-
PathBiMap
public PathBiMap()
-
-
Method Details
-
fromFileIdMap
Constructs a new PathBiMap from an existing map of fileIds to paths.- Parameters:
map
- fileId => paths map- Returns:
- PathBiMap
-
containsFileId
Indicates if the specified fileId is in the map- Parameters:
fileId
- fileId- Returns:
- true if it's in the map
-
containsPath
Indicates if the specified path is in the map- Parameters:
path
- path- Returns:
- true if it's in the map
-
put
Adds a new fileId => path mapping- Parameters:
fileId
- fileIdpath
- path
-
getPaths
Returns all of the paths associated to the fileId, or an empty set.- Parameters:
fileId
- fileId- Returns:
- set of paths
-
getFileId
Returns the fileId associated to the path or null- Parameters:
path
- path- Returns:
- fileId or null
-
removePath
Removes the path from the map. If it is the only path associated to a fileId, then the fileId is also removed.- Parameters:
path
- the path to remove- Returns:
- the fileId of the path that was removed or null
-
removeFileId
Removes a fileId from the map. All of its paths are also removed.- Parameters:
fileId
- the fileId to remove- Returns:
- the associated paths
-
getFileIdToPaths
Returns an immutable view of the PathBiMap, mapping fileIds to paths.- Returns:
- immutable fileId => paths map
-
getPathToFileId
Returns an immutable view of the PathBiMap, mapping paths to fileIds- Returns:
- immutable path => fileId map
-
toString
-
equals
-
hashCode
public int hashCode()
-