001package io.avaje.http.api;
002
003import java.lang.annotation.Retention;
004import java.lang.annotation.Target;
005
006import static java.lang.annotation.ElementType.PACKAGE;
007import static java.lang.annotation.ElementType.TYPE;
008import static java.lang.annotation.RetentionPolicy.RUNTIME;
009
010/**
011 * Marker annotation for client.
012 *
013 * <pre>{@code
014 *
015 *   @Client
016 *   interface CustomerApi {
017 *     ...
018 *     @Get("/{id}")
019 *     Customer getById(long id);
020 *
021 *     @Post
022 *     long save(Customer customer);
023 *   }
024 *
025 * }</pre>
026 *
027 * <h3>Client.Import</h3>
028 * <p>
029 * When the client interface already exists in another module we
030 * use <code>Client.Import</code> to generate the client.
031 * <p>
032 * Specify the <code>@Client.Import</code> on the package or class
033 * to refer to the client interface we want to generate.
034 *
035 * <pre>{@code
036 *
037 *   @Client.Import(types = OtherApi.class)
038 *   package org.example;
039 *
040 * }</pre>
041 */
042@Target(value = TYPE)
043@Retention(value = RUNTIME)
044public @interface Client {
045
046  @Target(value = {TYPE, PACKAGE})
047  @Retention(value = RUNTIME)
048  @interface Import {
049
050    /**
051     * Client interface types that we want to generate HTTP clients for.
052     */
053    Class<?>[] types();
054  }
055}