Enum Class FileMode
- All Implemented Interfaces:
Serializable, Comparable<FileMode>, Constable
Filesystem mode a scaffold-written file should carry on disk.
Declared per manifest entry via the optional mode key and
applied by ScaffoldApplier on POSIX filesystems. Three named
modes cover every scaffold file the manifest ships:
DEFAULT(0644) — ordinary tracked / tool-owned files; the implicit mode whenmodeis absent.EXECUTABLE(0755) — scripts that must run, e.g.mvnw. Without this the applier would publish them non-executable (every write goes through a 0600 temp file) and./mvnwwould fail.PRIVATE(0600) — owner-only, intentionally non-executable files, e.g. the parked VCS-bridge git hooks.
The string values are the mode: tokens authors write in
scaffold-manifest.yaml; fromManifest(Object) parses
them once at apply time, turning the YAML string into this enum so
the rest of the applier reasons over a type rather than a raw mode.
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescription0644 — owner read/write, group/other read.0755 — adds the executable bit for all; for runnable scripts.0600 — owner read/write only; non-executable and owner-private. -
Method Summary
Modifier and TypeMethodDescriptionstatic FileModefromManifest(Object raw) Resolve a manifestmodevalue to aFileMode.booleanWhether this mode was explicitly requested (anything other thanDEFAULT).The token used in a manifest entry'smodefield.intoctal()The POSIX mode bits this mode maps to.Expand this mode's octal bits into aPosixFilePermissionset suitable forFiles.setPosixFilePermissions(Path, Set).static FileModeReturns the enum constant of this class with the specified name.static FileMode[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
DEFAULT
0644 — owner read/write, group/other read. The implicit default. -
EXECUTABLE
0755 — adds the executable bit for all; for runnable scripts. -
PRIVATE
0600 — owner read/write only; non-executable and owner-private.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
manifestValue
The token used in a manifest entry'smodefield.- Returns:
- the lowercase manifest token (e.g.
"executable")
-
octal
public int octal()The POSIX mode bits this mode maps to.- Returns:
- octal permission bits (e.g.
0755)
-
isExplicit
public boolean isExplicit()Whether this mode was explicitly requested (anything other thanDEFAULT). Explicit modes are enforced on every write;DEFAULTpreserves a pre-existing file's permissions on update so the applier never loosens, say, a locked-down~/.m2/settings.xml.- Returns:
trueforEXECUTABLEandPRIVATE
-
fromManifest
Resolve a manifestmodevalue to aFileMode.- Parameters:
raw- the raw YAML value of the entry'smodekey;nullor blank yieldsDEFAULT- Returns:
- the matching mode
- Throws:
ScaffoldException- ifrawis a non-blank value that names no known mode
-
toPosixPermissions
Expand this mode's octal bits into aPosixFilePermissionset suitable forFiles.setPosixFilePermissions(Path, Set).- Returns:
- a fresh, mutable permission set
-