Enum Class FileMode

java.lang.Object
java.lang.Enum<FileMode>
network.ike.plugin.scaffold.FileMode
All Implemented Interfaces:
Serializable, Comparable<FileMode>, Constable

public enum FileMode extends Enum<FileMode>
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 when mode is 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 ./mvnw would 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.

  • Enum Constant Details

    • DEFAULT

      public static final FileMode DEFAULT
      0644 — owner read/write, group/other read. The implicit default.
    • EXECUTABLE

      public static final FileMode EXECUTABLE
      0755 — adds the executable bit for all; for runnable scripts.
    • PRIVATE

      public static final FileMode PRIVATE
      0600 — owner read/write only; non-executable and owner-private.
  • Method Details

    • values

      public static FileMode[] 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

      public static FileMode valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • manifestValue

      public String manifestValue()
      The token used in a manifest entry's mode field.
      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 than DEFAULT). Explicit modes are enforced on every write; DEFAULT preserves a pre-existing file's permissions on update so the applier never loosens, say, a locked-down ~/.m2/settings.xml.
      Returns:
      true for EXECUTABLE and PRIVATE
    • fromManifest

      public static FileMode fromManifest(Object raw)
      Resolve a manifest mode value to a FileMode.
      Parameters:
      raw - the raw YAML value of the entry's mode key; null or blank yields DEFAULT
      Returns:
      the matching mode
      Throws:
      ScaffoldException - if raw is a non-blank value that names no known mode
    • toPosixPermissions

      public Set<PosixFilePermission> toPosixPermissions()
      Expand this mode's octal bits into a PosixFilePermission set suitable for Files.setPosixFilePermissions(Path, Set).
      Returns:
      a fresh, mutable permission set