Class FileInputBuilder

java.lang.Object
com.dua3.utility.fx.controls.FileInputBuilder

public final class FileInputBuilder extends Object
Builder for creating instances of FileInput with customizable options. The builder provides methods to configure the file dialog mode, initial path, extension filters, validation, and disabled state.
  • Method Details

    • disabled

      public FileInputBuilder disabled(javafx.beans.value.ObservableValue<Boolean> disabled)
      Sets the 'disabled' property for the FileInput control.
      Parameters:
      disabled - an ObservableValue object representing the disabled state of the FileInput control
      Returns:
      the current instance of FileInputBuilder with the 'disabled' property set
    • validate

      public FileInputBuilder validate(Function<Path,Optional<String>> validate)
      Sets the validation function for the file input.
      Parameters:
      validate - a function that takes a Path and returns an Optional containing an error message if validation fails, or an empty Optional if validation succeeds
      Returns:
      the updated FileInputBuilder instance
    • initialPath

      public FileInputBuilder initialPath(@Nullable Path initialPath)
      Sets the initial path for the file input.
      Parameters:
      initialPath - the initial path to set, which may be null
      Returns:
      an instance of FileInputBuilder with the specified initial path
    • initialPath

      public FileInputBuilder initialPath(Supplier<Path> initialPath)
      Sets the initial path for the FileInputBuilder using the provided Supplier<Path>.
      Parameters:
      initialPath - a Supplier that provides the initial Path
      Returns:
      the FileInputBuilder instance with the updated initial path
    • filter

      public FileInputBuilder filter(javafx.stage.FileChooser.ExtensionFilter... filter)
      Adds the specified file extension filters to the FileChooser.
      Parameters:
      filter - One or more FileChooser.ExtensionFilter objects representing the file extension filters to be added.
      Returns:
      The current instance of FileInputBuilder, allowing for method chaining.
    • existingOnly

      public FileInputBuilder existingOnly(boolean flag)
      Sets the flag indicating whether only existing files or directories should be selectable.
      Parameters:
      flag - a boolean flag; if true, only existing files or directories can be selected, otherwise new ones can also be selected
      Returns:
      the current instance of FileInputBuilder for method chaining
    • build

      public FileInput build()
      Builds a FileInput object using the properties specified in the FileInputBuilder.
      Returns:
      a constructed FileInput control based on the current configuration.