Class MagicHttpClientProfile<C>

java.lang.Object
dev.ua.theroer.magicutils.http.MagicHttpClientProfile<C>
Type Parameters:
C - config type driving the profile
All Implemented Interfaces:
AutoCloseable

public final class MagicHttpClientProfile<C> extends Object implements AutoCloseable
High-level runtime profile for named MagicHttpClient instances.

The profile is backed by a MagicRuntimeConfigBinding, keeps the client registered under a stable runtime name, and rebuilds it automatically when matching config sections change.

  • Method Details

    • builder

      public static <C> MagicHttpClientProfile.Builder<C> builder(MagicRuntime runtime, String name, Class<C> configClass)
      Creates a profile builder.
      Type Parameters:
      C - config type
      Parameters:
      runtime - runtime that owns the client
      name - runtime component name
      configClass - config class driving the client
      Returns:
      builder instance
    • name

      public String name()
      Returns the runtime name of this profile.
      Returns:
      profile name
    • binding

      Returns the underlying runtime binding.
      Returns:
      config binding
    • current

      public Optional<MagicHttpClient> current()
      Returns the current client when available.
      Returns:
      optional current client
    • require

      public MagicHttpClient require()
      Returns the current client or throws when unavailable.
      Returns:
      current client
    • refresh

      public MagicHttpClient refresh()
      Rebuilds the current client from the latest config.
      Returns:
      rebuilt client
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable