# Class RestClients

java.lang.Object
com.codename1.io.rest.RestClients

public final class RestClients extends Object
Runtime registry that wires `@RestClient`-annotated interfaces to the build-time-generated implementations. The generated `cn1app.RestClientBootstrap` calls `register(Class, Factory)` for every API interface in the project; user code reaches them via the `static of(String baseUrl)` factory that `cn1:generate-openapi` puts on each interface, and that factory in turn calls `create(Class, String)` here.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `RestClients.Factory<T>`
  Factory the generated bootstrap registers per API interface.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <T> T`
  `create(Class<T> apiType, String baseUrl)`
  Returns a freshly-built client for the requested API.
  `static <T> void`
  `register(Class<T> apiType, RestClients.Factory<T> factory)`
  Registers a factory for an `@RestClient`-annotated interface.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### register

    public static <T> void register(Class<T> apiType, RestClients.Factory<T> factory)
    Registers a factory for an `@RestClient`-annotated interface. Called from the generated `cn1app.RestClientBootstrap` so the REST plumbing is set up before the first `<Api>.of(baseUrl)` call.

  - ### create

    public static <T> T create(Class<T> apiType, String baseUrl)
    Returns a freshly-built client for the requested API. Called by the `static of(String baseUrl)` factory emitted on every generated `@RestClient` interface.