Package edu.cnu.mdi.dialog
Record Class FileType
java.lang.Object
java.lang.Record
edu.cnu.mdi.dialog.FileType
- Record Components:
description- user-facing filter descriptionextensions- accepted extensions, without leading dots
Describes one file type used by
FileDialogs.
Extensions are stored without a leading dot and compared
case-insensitively. The first extension is the preferred extension appended
by ensureExtension(Path) when a save target has none of the accepted
suffixes.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thedescriptionrecord component.ensureExtension(Path path) Ensures that a save path has one of the accepted extensions.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theextensionsrecord component.final inthashCode()Returns a hash code value for this object.static FileTypeConvenience factory accepting varargs extensions.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
FileType
Validates and defensively copies this file-type definition.- Throws:
NullPointerException- if the description, list, or an extension is nullIllegalArgumentException- if the description is blank, the list is empty, or an extension is blank
-
-
Method Details
-
of
Convenience factory accepting varargs extensions.- Parameters:
description- user-facing descriptionextensions- accepted extensions- Returns:
- validated file type
-
toSwingFilter
- Returns:
- Swing chooser filter corresponding to this definition
-
ensureExtension
Ensures that a save path has one of the accepted extensions.- Parameters:
path- proposed path- Returns:
- original path when accepted, otherwise a sibling path with the preferred extension appended
-
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. -
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. -
equals
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. All components in this record class are compared withObjects::equals(Object,Object). -
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-
extensions
Returns the value of theextensionsrecord component.- Returns:
- the value of the
extensionsrecord component
-