Class NtfyConfig.Builder

java.lang.Object
io.github.pimak.ntfy.core.NtfyConfig.Builder
Enclosing class:
NtfyConfig

public static final class NtfyConfig.Builder extends Object
Fluent builder for NtfyConfig; every setter returns this.
  • Method Details

    • url

      public NtfyConfig.Builder url(String url)
    • topic

      public NtfyConfig.Builder topic(String topic)
    • token

      public NtfyConfig.Builder token(String token)
    • username

      public NtfyConfig.Builder username(String username)
    • password

      public NtfyConfig.Builder password(String password)
    • title

      public NtfyConfig.Builder title(String title)
    • appName

      public NtfyConfig.Builder appName(String appName)
    • maxStackFrames

      public NtfyConfig.Builder maxStackFrames(int maxStackFrames)
    • connectTimeout

      public NtfyConfig.Builder connectTimeout(Duration connectTimeout)
    • requestTimeout

      public NtfyConfig.Builder requestTimeout(Duration requestTimeout)
    • maxAlertsPerWindow

      public NtfyConfig.Builder maxAlertsPerWindow(int maxAlertsPerWindow)
    • suppressionWindow

      public NtfyConfig.Builder suppressionWindow(Duration suppressionWindow)
    • errorPriority

      public NtfyConfig.Builder errorPriority(String errorPriority)
    • digestPriority

      public NtfyConfig.Builder digestPriority(String digestPriority)
    • errorTags

      public NtfyConfig.Builder errorTags(String errorTags)
    • digestTags

      public NtfyConfig.Builder digestTags(String digestTags)
    • warnTopic

      public NtfyConfig.Builder warnTopic(String warnTopic)
      The topic WARN-level events are published to. Setting it to a non-blank value is the entire opt-in for WARN alerting — see NtfyConfig.isWarnRoutingEnabled(). null/blank (the default) keeps alerting ERROR-only.
    • warnPriority

      public NtfyConfig.Builder warnPriority(String warnPriority)
      ntfy Priority header for WARN alerts and the WARN digest; default default.
    • warnTags

      public NtfyConfig.Builder warnTags(String warnTags)
      ntfy Tags header for WARN alerts and the WARN digest; default warning.
    • warnTopicFromClasspathFile

      public NtfyConfig.Builder warnTopicFromClasspathFile(boolean warnTopicFromClasspathFile)
    • clickUrl

      public NtfyConfig.Builder clickUrl(String clickUrl)
      URL opened when a notification is tapped (ntfy Click header); null to omit.
    • actionsHeader

      public NtfyConfig.Builder actionsHeader(String actionsHeader)
      Sets action buttons from a raw, pre-formatted ntfy Actions header value (the short "simple" format, e.g. "view, View logs, https://grafana.example.com/d/abc"). Forwarded verbatim; null/blank sends no Actions header. This is the flat-string entry point used by environment/YAML/XML configuration.
    • actions

      public NtfyConfig.Builder actions(List<NtfyAction> actions)
      Sets action buttons from typed NtfyActions, serialized to the ntfy Actions header via NtfyActionSerializer. ntfy caps a notification at three actions; extra entries and null elements are dropped. A null/empty list sends no Actions header. Constructing an individual NtfyAction with a blank label/url throws.
    • excludedLoggerPrefixes

      public NtfyConfig.Builder excludedLoggerPrefixes(List<String> prefixes)
      Sets the excluded logger prefixes from an explicit list (defensively copied, null-safe).
    • excludedLoggers

      public NtfyConfig.Builder excludedLoggers(String csv)
      Convenience: sets the excluded logger prefixes from a single comma-separated string, trimming each entry and dropping blanks. A null/blank csv clears the list.
    • excludedExceptionTypes

      public NtfyConfig.Builder excludedExceptionTypes(List<String> types)
      Sets the excluded exception types from an explicit list of fully qualified class names (defensively copied, null-safe, blanks dropped).
    • excludedExceptionTypesCsv

      public NtfyConfig.Builder excludedExceptionTypesCsv(String csv)
      Convenience: sets the excluded exception types from a single comma-separated string of fully qualified class names, trimming each entry and dropping blanks. A null/blank csv clears the list. This is the spelling every adapter's flat configuration surface uses.
    • cache

      public NtfyConfig.Builder cache(boolean cache)
      false asks the server not to store the message (Cache: no), at the cost of every subscriber who is not connected at that moment. Default true.
    • cache

      public NtfyConfig.Builder cache(String cache)
      Sets cache from a raw configuration string, the spelling every flat surface hands over — an XML attribute, an environment variable, a properties entry.

      Exists so the answer to "what does cache=yes mean" cannot differ between surfaces. Each adapter converting on its own gets Boolean.valueOf, which maps everything that is not "true" to false — so yes would turn caching OFF and cost every offline subscriber their alerts, silently, on exactly the surfaces where the value is typed by hand. A null leaves the default; an unreadable value leaves the default and is recorded for the engine to warn about at start().

    • firebase

      public NtfyConfig.Builder firebase(String firebase)
      firebase from a raw configuration string. See cache(String).
    • firebase

      public NtfyConfig.Builder firebase(boolean firebase)
      false asks the server not to forward the message to Firebase (Firebase: no), at the cost of push latency on the Google Play Android client. Default true.

      Independent of cache(boolean) on purpose: a self-hosted server with no FCM configured wants this off and caching on, and one combined switch would make that unreachable.

    • icon

      public NtfyConfig.Builder icon(String icon)
      Sets the notification icon URL (ntfy Icon header). Must be an http/ https URL; a value that is not one is dropped with a diagnostic at start() rather than sent. ntfy renders JPEG and PNG only, but the format is a property of the bytes served rather than of the path, so an extension naming another format only earns a warning.
    • iconsByLoggerPrefix

      public NtfyConfig.Builder iconsByLoggerPrefix(Map<String,String> icons)
      Sets the logger-prefix → icon-URL table (defensively copied, null-safe). An entry with a blank half, or one whose URL no client could fetch, is dropped with a diagnostic at start(), leaving the rest of the table working. A URL naming a format ntfy does not render is warned about but kept — the format lives in the bytes, not in the path.
    • iconsByLoggerPrefixCsv

      public NtfyConfig.Builder iconsByLoggerPrefixCsv(String csv)
      Convenience: the same table as a single string, prefix=url pairs separated by commas — the spelling every adapter's flat configuration surface uses. Only the FIRST = of a pair separates prefix from URL, so a query string may contain more.
    • includeMdcKeys

      public NtfyConfig.Builder includeMdcKeys(List<String> keys)
      Sets the MDC-key allow-list from an explicit list (defensively copied, null-safe); a null list clears it. Order is preserved and is the order the entries are rendered in. See NtfyConfig.getIncludeMdcKeys() — there is no wildcard form on purpose.
    • includeMdcKeysCsv

      public NtfyConfig.Builder includeMdcKeysCsv(String csv)
      Convenience: sets the MDC-key allow-list from a single comma-separated string, trimming each entry and dropping blanks. A null/blank csv clears the list. This is the flat-string entry point used by environment/properties configuration.

      Deliberately a distinct method rather than a String/List overload pair (matching the existing excludedLoggerPrefixes/excludedLoggers(java.lang.String) precedent): an overload would make a bare null literal ambiguous at the call site.

      Limitation: an MDC key containing a comma is unreachable from any CSV surface — use includeMdcKeys(List) for that.

    • enabled

      public NtfyConfig.Builder enabled(boolean enabled)
    • asyncEnabled

      public NtfyConfig.Builder asyncEnabled(boolean asyncEnabled)
      Toggles asynchronous (offloaded) delivery of individual error alerts. On by default; set false for pre-2.0 synchronous delivery. See NtfyConfig.isAsyncEnabled().
    • asyncQueueCapacity

      public NtfyConfig.Builder asyncQueueCapacity(int asyncQueueCapacity)
      Sets the bounded async delivery queue capacity (see NtfyConfig.getAsyncQueueCapacity()). A non-positive value is clamped to a safe minimum by the engine at start.
    • requireHttpsForCredentials

      public NtfyConfig.Builder requireHttpsForCredentials(boolean requireHttpsForCredentials)
      Toggles refusing activation when credentials would traverse a cleartext http:// endpoint. On by default; set false for the pre-2.0 warn-and-activate behavior. See NtfyConfig.isRequireHttpsForCredentials().
    • endpointFromClasspathFile

      public NtfyConfig.Builder endpointFromClasspathFile(boolean endpointFromClasspathFile)
    • allowClasspathEndpoint

      public NtfyConfig.Builder allowClasspathEndpoint(boolean allowClasspathEndpoint)
      Explicit opt-in for activating from a classpath-only endpoint URL; see NtfyConfig.isAllowClasspathEndpoint(). Off by default.
    • startupPing

      public NtfyConfig.Builder startupPing(StartupPingMode startupPing)
      Selects the opt-in startup self-test mode (see NtfyConfig.getStartupPing()). A null argument resets to the StartupPingMode.OFF default.
    • startupPing

      public NtfyConfig.Builder startupPing(String startupPing)
      Convenience overload parsing a configured string (off/probe/publish, case-insensitive) so the XML and properties surfaces bind without carrying their own parser.

      A null/blank tag keeps the current value, and an UNRECOGNISED value keeps it too rather than throwing — the same lenient contract as locale(String) and the numeric setters, so one typo in a config file can never take down the host application. The engine warns about the typo at start (it can tell "unset" from "unparseable" because StartupPingMode.fromValue(java.lang.String) returns null only for the latter), and the caller may pre-check with fromValue when it wants to warn earlier.

    • startupPingFailFast

      public NtfyConfig.Builder startupPingFailFast(boolean startupPingFailFast)
      Toggles aborting application startup when the self-test fails; see NtfyConfig.isStartupPingFailFast(). Off by default, and also switches the self-test from background to inline execution when on.
    • startupPingWarn

      public NtfyConfig.Builder startupPingWarn(StartupPingMode startupPingWarn)
      Selects the startup self-test mode for the WARN route (see NtfyConfig.getStartupPingWarn()). A null argument resets to StartupPingMode.OFF.
    • startupPingWarn

      public NtfyConfig.Builder startupPingWarn(String startupPingWarn)
      Lenient string overload for startup-ping-warn; see startupPing(String).
    • startupPingNotifyFailures

      public NtfyConfig.Builder startupPingNotifyFailures(boolean startupPingNotifyFailures)
      Toggles announcing a failed self-test on a route that passed; see NtfyConfig.isStartupPingNotifyFailures(). On by default.
    • locale

      public NtfyConfig.Builder locale(Locale locale)
      Sets the language of notification bodies and diagnostics (see NtfyConfig.getLocale()). A null argument resets to the Locale.ENGLISH default.
    • locale

      public NtfyConfig.Builder locale(String languageTag)
      Convenience overload that parses a BCP 47 language tag (e.g. "fr", "de-DE") via Locale.forLanguageTag(String). A null/blank tag, or one whose language subtag is undetermined (garbage input, bare "und", "und-Latn", private-use "x-..." — all of which parse to an empty Locale.getLanguage()), keeps the Locale.ENGLISH default rather than silently selecting the undetermined locale.
    • build

      public NtfyConfig build()