Class FileIOError

java.lang.Object
com.helger.io.file.FileIOError
All Implemented Interfaces:
com.helger.base.state.ISuccessIndicator

@Immutable public class FileIOError extends Object implements com.helger.base.state.ISuccessIndicator
Represents an error with an additional error object.
Author:
Philip Helger
  • Constructor Details

    • FileIOError

      public FileIOError(@NonNull EFileIOOperation eOperation, @NonNull EFileIOErrorCode eCode)
      Constructor with operation and error code only.
      Parameters:
      eOperation - The file I/O operation. May not be null.
      eCode - The error code. May not be null.
    • FileIOError

      public FileIOError(@NonNull EFileIOOperation eOperation, @NonNull EFileIOErrorCode eCode, @NonNull File aFile1)
      Constructor with operation, error code and one file.
      Parameters:
      eOperation - The file I/O operation. May not be null.
      eCode - The error code. May not be null.
      aFile1 - The first file relevant to this error. May not be null.
    • FileIOError

      public FileIOError(@NonNull EFileIOOperation eOperation, @NonNull EFileIOErrorCode eCode, @NonNull File aFile1, @NonNull File aFile2)
      Constructor with operation, error code and two files.
      Parameters:
      eOperation - The file I/O operation. May not be null.
      eCode - The error code. May not be null.
      aFile1 - The first file relevant to this error. May not be null.
      aFile2 - The second file relevant to this error. May not be null.
    • FileIOError

      public FileIOError(@NonNull EFileIOOperation eOperation, @NonNull EFileIOErrorCode eCode, @NonNull Exception aException)
      Constructor with operation, error code and an exception.
      Parameters:
      eOperation - The file I/O operation. May not be null.
      eCode - The error code. May not be null.
      aException - The exception that occurred. May not be null.
    • FileIOError

      public FileIOError(@NonNull EFileIOOperation eOperation, @NonNull EFileIOErrorCode eCode, @Nullable File aFile1, @Nullable File aFile2, @Nullable Exception aException)
      Full constructor with all parameters.
      Parameters:
      eOperation - The file I/O operation. May not be null.
      eCode - The error code. May not be null.
      aFile1 - The first file relevant to this error. May be null.
      aFile2 - The second file relevant to this error. May be null.
      aException - The exception that occurred. May be null.
  • Method Details

    • getOperation

      public @NonNull EFileIOOperation getOperation()
      Returns:
      The operation passed in the constructor. Never null.
    • getErrorCode

      public @NonNull EFileIOErrorCode getErrorCode()
      Returns:
      The error code passed in the constructor. Never null.
    • isSuccess

      public boolean isSuccess()
      Check if this error represents a successful operation.
      Specified by:
      isSuccess in interface com.helger.base.state.ISuccessIndicator
      Returns:
      true if the operation was successful, false otherwise.
    • getFile1

      public @Nullable File getFile1()
      Returns:
      The first file relevant to this error. May be null.
    • hasFile1

      public boolean hasFile1()
      Returns:
      true if the first file is present, false if not.
    • getFile2

      public @Nullable File getFile2()
      Returns:
      The second file relevant to this error. May be null. This field can only be present, if getFile1() is present.
    • hasFile2

      public boolean hasFile2()
      Returns:
      true if the second file is present, false if not.
    • getException

      public @Nullable Exception getException()
      Returns:
      The exception passed in the constructor. May be null.
    • hasException

      public boolean hasException()
      Returns:
      true if an exception is present, false if not.
    • withoutErrorCode

      public @NonNull FileIOError withoutErrorCode()
      Create a copy of this error with the error code reset to EFileIOErrorCode.NO_ERROR. If the current error code already indicates success, this is returned.
      Returns:
      A non-null FileIOError with no error code.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object