Package org.approvej.approve
Record Class PathProvider
java.lang.Object
java.lang.Record
org.approvej.approve.PathProvider
- Record Components:
directory- thePathcontaining theapprovedPath()and thereceivedPath()baseFilename- the first part of the filename used to identify the test class and case the files belong tofilenameAffix- an addition to the baseFilename to identify multiple files belonging to the same test caseapprovedLabel- a label to identify the approved file – usually "approved", but can be left emptyfilenameExtension- the filename extension for the approved and received file
@NullMarked
public record PathProvider(Path directory, String baseFilename, String filenameAffix, String approvedLabel, String filenameExtension)
extends Record
A record to provide the paths of the approved and received files.
Generally, the constructor should not be used, but one of the PathProviders
initializers.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theapprovedLabelrecord component.Resolves and returns thePathto the received file in thedirectory, using thebaseFilename, followed byapprovedLabel(if any), followed by thefilenameExtension(if any).Returns the value of thebaseFilenamerecord component.Returns the value of thedirectoryrecord component.Set thedirectorywhere the approved and received files are stored.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefilenameAffixrecord component.filenameAffix(String filenameAffix) Extends thebaseFilenamewith the givenString.Returns the value of thefilenameExtensionrecord component.filenameExtension(String filenameExtension) Creates a newPathProviderwith the current values and the given filenameExtension, unless the currently setfilenameExtensionis not empty and given is the default "txt"<T>.final inthashCode()Returns a hash code value for this object.Resolves and returns thePathto the received file in thedirectory, using thebaseFilename, followed by "received" (if any), followed by thefilenameExtension(if any).final StringtoString()Returns a string representation of this record class.
-
Field Details
-
RECEIVED
The infix of the file containing the latest received value that didn't match the previously approved.- See Also:
-
APPROVED
The infix of the file containing a previously approved value.- See Also:
-
-
Constructor Details
-
PathProvider
public PathProvider(Path directory, String baseFilename, String filenameAffix, String approvedLabel, String filenameExtension) Creates an instance of aPathProviderrecord class.- Parameters:
directory- the value for thedirectoryrecord componentbaseFilename- the value for thebaseFilenamerecord componentfilenameAffix- the value for thefilenameAffixrecord componentapprovedLabel- the value for theapprovedLabelrecord componentfilenameExtension- the value for thefilenameExtensionrecord component
-
-
Method Details
-
directory
Set thedirectorywhere the approved and received files are stored.- Parameters:
directory- thePathwhere the approved and received files are stored- Returns:
- a copy of this with the given
directory
-
filenameAffix
Extends thebaseFilenamewith the givenString.- Parameters:
filenameAffix- affix to add to the base filename- Returns:
- a copy of this using the
baseFilenameaffixed by the givenString
-
filenameExtension
Creates a newPathProviderwith the current values and the given filenameExtension, unless the currently setfilenameExtensionis not empty and given is the default "txt"<T>.- Parameters:
filenameExtension- the filename extension to use- Returns:
- a copy of this with using the given filenameExtension
-
approvedPath
Resolves and returns thePathto the received file in thedirectory, using thebaseFilename, followed byapprovedLabel(if any), followed by thefilenameExtension(if any).- Returns:
- the absolute and normalized
Pathto the approved file
-
receivedPath
Resolves and returns thePathto the received file in thedirectory, using thebaseFilename, followed by "received" (if any), followed by thefilenameExtension(if any).- Returns:
- the absolute and normalized
Pathto the received file
-
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). -
directory
Returns the value of thedirectoryrecord component.- Returns:
- the value of the
directoryrecord component
-
baseFilename
Returns the value of thebaseFilenamerecord component.- Returns:
- the value of the
baseFilenamerecord component
-
filenameAffix
Returns the value of thefilenameAffixrecord component.- Returns:
- the value of the
filenameAffixrecord component
-
approvedLabel
Returns the value of theapprovedLabelrecord component.- Returns:
- the value of the
approvedLabelrecord component
-
filenameExtension
Returns the value of thefilenameExtensionrecord component.- Returns:
- the value of the
filenameExtensionrecord component
-