Record Class ExtensionFilter

java.lang.Object
java.lang.Record
one.jpro.platform.file.ExtensionFilter
Record Components:
description - the textual description for the filter
extensions - a list of the accepted file name extensions

public record ExtensionFilter(String description, boolean allowDirectory, List<String> extensions) extends Record
Creates an ExtensionFilter with the specified description and the file name extensions.

File name extension should be specified in the *.<extension> format.

Author:
Besmir Beqiri
  • Field Details

  • Constructor Details

    • ExtensionFilter

      public ExtensionFilter(String description, boolean allowDirectory, List<String> extensions)
      Compact constructor for ExtensionFilter.
      Throws:
      NullPointerException - if the description or the extensions are null
      IllegalArgumentException - if the description or the extensions are empty
    • ExtensionFilter

      public ExtensionFilter(String description, String... extension)
      Constructor for ExtensionFilter with a single extension.
      Parameters:
      description - the description of the filter
      extension - the extension to filter
      Throws:
      NullPointerException - if the description or the extension are null
      IllegalArgumentException - if the description or the extension are empty
  • Method Details

    • of

      public static ExtensionFilter of(String description, String... extensions)
      Creates an ExtensionFilter with the specified description and the file name extensions.

      File name extension should be specified in the *.<extension> format.

      Parameters:
      description - the textual description for the filter
      extensions - an array of the accepted file name extensions
      Returns:
      the created ExtensionFilter
      Throws:
      NullPointerException - if the description or the extensions are null
      IllegalArgumentException - if the description or the extensions are empty
    • of

      public static ExtensionFilter of(String description, boolean allowDirectory, String... extensions)
      Creates an ExtensionFilter with the specified description and the file name extensions.

      File name extension should be specified in the *.<extension> format.

      Parameters:
      description - the textual description for the filter
      extensions - an array of the accepted file name extensions
      Returns:
      the created ExtensionFilter
      Throws:
      NullPointerException - if the description or the extensions are null
      IllegalArgumentException - if the description or the extensions are empty
    • toJavaFXExtensionFilter

      public static javafx.stage.FileChooser.ExtensionFilter toJavaFXExtensionFilter(ExtensionFilter extensionFilter)
      Converts this ExtensionFilter to a JavaFX FileChooser.ExtensionFilter.
      Returns:
      a corresponding FileChooser.ExtensionFilter instance
    • fromJavaFXExtensionFilter

      public static ExtensionFilter fromJavaFXExtensionFilter(javafx.stage.FileChooser.ExtensionFilter extensionFilter)
      Converts a JavaFX FileChooser.ExtensionFilter to an ExtensionFilter.
      Parameters:
      extensionFilter - the JavaFX FileChooser.ExtensionFilter to convert
      Returns:
      the corresponding ExtensionFilter instance
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • description

      public String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • allowDirectory

      public boolean allowDirectory()
      Returns the value of the allowDirectory record component.
      Returns:
      the value of the allowDirectory record component
    • extensions

      public List<String> extensions()
      Returns the value of the extensions record component.
      Returns:
      the value of the extensions record component