Package org.opentest4j
Class FileInfo
- java.lang.Object
-
- org.opentest4j.FileInfo
-
- All Implemented Interfaces:
java.io.Serializable
public class FileInfo extends java.lang.Object implements java.io.Serializable
FileInfo
is a pair of a file path and the contents of the file.Its main use case is for
actual
andexpected
values inAssertionFailedError
.The semantics of the
path
can be defined by the users of this class.- Since:
- 1.3
- Author:
- Marc Philipp, Reinhold Degenfellner
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FileInfo(java.lang.String path, byte[] contents)
Constructs aFileInfo
with a path to a file and the contents of the file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Determines if the supplied object is an instance ofFileInfo
with the same path and contents as thisFileInfo
.byte[]
getContents()
Returns the contents of the file.java.lang.String
getContentsAsString(java.nio.charset.Charset charset)
Returns the contents of the file as aString
.java.lang.String
getPath()
Returns the path to the file.int
hashCode()
Generates a unique hash code for thisFileInfo
based on itspath
.java.lang.String
toString()
-
-
-
Constructor Detail
-
FileInfo
public FileInfo(java.lang.String path, byte[] contents)
Constructs aFileInfo
with a path to a file and the contents of the file.Be cautious with large files (limiting the size may be a good idea).
The supplied byte array is not copied to avoid unnecessary memory allocations. However, callers of this constructors should not modify the byte array after calling this constructor. This behavior may change in a future release without prior notice.
- Parameters:
path
- the path to the file; must not benull
contents
- the contents of the file; must not benull
;
-
-
Method Detail
-
getPath
public java.lang.String getPath()
Returns the path to the file.- Returns:
- the path to the file; never
null
-
getContents
public byte[] getContents()
Returns the contents of the file.This method does currently not return a defensive copy of the contained byte array to avoid unnecessary memory allocations. However, callers of this method should not modify the returned byte array. This behavior may change in a future release without prior notice.
- Returns:
- the contents of the file; never
null
-
getContentsAsString
public java.lang.String getContentsAsString(java.nio.charset.Charset charset)
Returns the contents of the file as aString
.- Returns:
- the contents of the file as a
String
; nevernull
-
equals
public boolean equals(java.lang.Object obj)
Determines if the supplied object is an instance ofFileInfo
with the same path and contents as thisFileInfo
.- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
Generates a unique hash code for thisFileInfo
based on itspath
.- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-