Class Platform.Builder

java.lang.Object
be.imgn.gaia.platform.Platform.Builder
Enclosing interface:
Platform

public static final class Platform.Builder extends Object
Detects a Platform from its sources. Each source defaults to the running JVM's: SystemProperties.system(), Environment.system() and FileSystems.getDefault().

The operating system comes from the os.name property; any value not recognized as Linux, macOS or Windows is taken for another Unix-like system. Every path of the platform belongs to the file system.

  • Method Details

    • systemProperties

      public Platform.Builder systemProperties(SystemProperties systemProperties)
      Sets the system properties to read; os.name and user.home are required.
      Parameters:
      systemProperties - the system properties
      Returns:
      this builder
    • environment

      public Platform.Builder environment(Environment environment)
      Sets the environment variables to read.
      Parameters:
      environment - the environment variables
      Returns:
      this builder
    • fileSystem

      public Platform.Builder fileSystem(FileSystem fileSystem)
      Sets the file system the platform's paths belong to.
      Parameters:
      fileSystem - the file system
      Returns:
      this builder
    • detect

      public Platform detect()
      Detects the platform from this builder's sources. The sources are read now; later changes to them do not affect the platform.
      Returns:
      the platform
      Throws:
      NoSuchElementException - if os.name or user.home is not set
      InvalidPathException - if user.home, or an environment variable the platform reads a directory from, is not a valid path on the file system