Class Configuration.Builder
java.lang.Object
be.imgn.gaia.memfs.Configuration.Builder
- Enclosing class:
Configuration
A builder of
Configurations.- Since:
- 0.1.1
-
Method Summary
Modifier and TypeMethodDescriptionattributeViews(String... views) Sets the supported attribute views: any ofbasic,owner,posix,unix,dos,aclanduser.blockSize(int bytes) Sets the size of the blocks the content of files is stored in.build()Builds the configuration.clock(InstantSource source) Sets the clock that dates the creation, modification and access of files.currentUser(String user, String... groups) Enforces permissions, checking them against a user and their groups.defaultAttribute(String attribute, Object value) Sets an attribute new files get unless they are given it:owner:owner(a user name),posix:group(a group name),posix:permissions(aSet<PosixFilePermission>or a string such asrw-r--r--),dos:readonly,dos:hidden,dos:systemordos:archive(aBoolean), oracl:acl(aList<AclEntry>).Sets the optional features the file system has; it lacks the others.maxNameLength(int characters) Sets how long a name may be.maxSize(long bytes) Sets the capacity of the file system.nameMatching(NameMatching matching) Sets how names are matched when files are looked up.Stops enforcing permissions.Sets the root directories.unicodeNormalization(@Nullable Normalizer.Form form) Sets the Unicode normalization names are matched under: with any form, a name written with composed or decomposed characters names the same file.watchServicePollingInterval(Duration interval) Sets how often a watch service looks for changes in the directories it watches.workingDirectory(String path) Sets the working directory, which relative paths are resolved against.
-
Method Details
-
roots
Sets the root directories. A Unix-style file system has the one root/; a Windows-style one has drives, such asC:\, and UNC shares, such as\\server\share\.- Parameters:
first- the first rootmore- the other roots- Returns:
- this builder
- Throws:
IllegalArgumentException- if a root is not the root of an absolute path of the style, is given twice, or a Unix-style file system is given another root than/
-
workingDirectory
Sets the working directory, which relative paths are resolved against. It is created with the file system, with the directories it is in.- Parameters:
path- the absolute path of the directory, on one of the roots- Returns:
- this builder
-
blockSize
Sets the size of the blocks the content of files is stored in.- Parameters:
bytes- the block size, in bytes- Returns:
- this builder
- Throws:
IllegalArgumentException- if the size is not positive
-
maxSize
Sets the capacity of the file system. Writing past it throws aFileSystemException.- Parameters:
bytes- the capacity, in bytes- Returns:
- this builder
- Throws:
IllegalArgumentException- if the capacity is not positive
-
nameMatching
Sets how names are matched when files are looked up.- Parameters:
matching- the name matching- Returns:
- this builder
-
unicodeNormalization
Sets the Unicode normalization names are matched under: with any form, a name written with composed or decomposed characters names the same file. Names are still shown as they were created.- Parameters:
form- the normalization form, ornullto match names as they are- Returns:
- this builder
-
attributeViews
Sets the supported attribute views: any ofbasic,owner,posix,unix,dos,aclanduser. The file system also supportsbasicand the views these extend, asposixextendsowner.- Parameters:
views- the names of the views- Returns:
- this builder
- Throws:
IllegalArgumentException- if a view is unknown
-
defaultAttribute
Sets an attribute new files get unless they are given it:owner:owner(a user name),posix:group(a group name),posix:permissions(aSet<PosixFilePermission>or a string such asrw-r--r--),dos:readonly,dos:hidden,dos:systemordos:archive(aBoolean), oracl:acl(aList<AclEntry>). Its view must be supported when the configuration is built.- Parameters:
attribute- the attribute, asview:namevalue- the value- Returns:
- this builder
- Throws:
IllegalArgumentException- if the attribute is not one of these, or the value has the wrong type
-
clock
Sets the clock that dates the creation, modification and access of files.- Parameters:
source- the clock- Returns:
- this builder
-
watchServicePollingInterval
Sets how often a watch service looks for changes in the directories it watches.- Parameters:
interval- the interval- Returns:
- this builder
- Throws:
IllegalArgumentException- if the interval is not positive
-
features
Sets the optional features the file system has; it lacks the others.- Parameters:
supported- the features- Returns:
- this builder
-
maxNameLength
Sets how long a name may be. Creating a file with a longer name throws aFileSystemException.- Parameters:
characters- the maximum length, in characters- Returns:
- this builder
- Throws:
IllegalArgumentException- if the length is not positive
-
currentUser
Enforces permissions, checking them against a user and their groups. The files the user creates belong to them and to their first group, unlessowner:ownerandposix:grouphave defaults.- Parameters:
user- the user namegroups- the groups of the user- Returns:
- this builder
-
noCurrentUser
Stops enforcing permissions. They are still stored.- Returns:
- this builder
-
build
Builds the configuration.- Returns:
- the configuration
- Throws:
IllegalArgumentException- if the working directory is not an absolute path on one of the roots, the block size is larger than the capacity, or a default attribute is of a view that is not supported
-