Record Class PublishResult

java.lang.Object
java.lang.Record
io.github.pimak.ntfy.core.PublishResult
Record Components:
success - whether the ntfy server accepted the request (HTTP 2xx)
httpStatus - the HTTP status code, or null if the request never reached the server (timeout, connection refused, malformed request, interrupted)
message - null on success; a fixed, credential-safe description on failure

public record PublishResult(boolean success, Integer httpStatus, String message) extends Record
Outcome of a single NtfyPublisher.publish(java.lang.String, java.lang.String, java.lang.String, io.github.pimak.ntfy.core.AuthMode, java.lang.String) call.

Local, dependency-free result type — deliberately framework-agnostic, with no dependency on any external notification-result type. message is always a fixed, safe-to-surface string; it must never carry a plaintext credential.

  • Constructor Details

    • PublishResult

      public PublishResult(boolean success, Integer httpStatus, String message)
      Creates an instance of a PublishResult record class.
      Parameters:
      success - the value for the success record component
      httpStatus - the value for the httpStatus record component
      message - the value for the message record component
  • Method Details

    • success

      public static PublishResult success(int httpStatus)
    • failure

      public static PublishResult failure(String message)
    • failure

      public static PublishResult failure(int httpStatus, String message)
    • 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.
    • success

      public boolean success()
      Returns the value of the success record component.
      Returns:
      the value of the success record component
    • httpStatus

      public Integer httpStatus()
      Returns the value of the httpStatus record component.
      Returns:
      the value of the httpStatus record component
    • message

      public String message()
      Returns the value of the message record component.
      Returns:
      the value of the message record component