Class ReflectiveRestClientValidator

java.lang.Object
com.shri.restinpeace.validator.ReflectiveRestClientValidator

public class ReflectiveRestClientValidator extends Object
Validates a @RestClient interface before RIP.getClient(Class) hands back a proxy for it, so a misconfigured interface fails fast with a complete list of problems instead of failing later on the first call.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> void
    validate(Class<T> restClient)
    Validates the given interface, collecting every problem found (missing @RestClient, missing/duplicate HTTP method annotations, invalid URLs, unmatched path params, misused @Body, unsupported CompletableFuture type parameters) rather than stopping at the first one.
    static <T> void
    validate(Class<T> restClient, String baseUrlOverride)
    Same as validate(Class), but a relative method URL is validated against baseUrlOverride instead of requiring @BaseUrl on the interface - for RIP.getClient(Class, String), where the base URL is supplied at runtime instead of declared on the interface.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • validate

      public static <T> void validate(Class<T> restClient) throws RestInPeaceValidationException
      Validates the given interface, collecting every problem found (missing @RestClient, missing/duplicate HTTP method annotations, invalid URLs, unmatched path params, misused @Body, unsupported CompletableFuture type parameters) rather than stopping at the first one.
      Type Parameters:
      T - the rest client interface type
      Parameters:
      restClient - the interface to validate
      Throws:
      RestInPeaceValidationException - if any validation error is found
    • validate

      public static <T> void validate(Class<T> restClient, String baseUrlOverride) throws RestInPeaceValidationException
      Same as validate(Class), but a relative method URL is validated against baseUrlOverride instead of requiring @BaseUrl on the interface - for RIP.getClient(Class, String), where the base URL is supplied at runtime instead of declared on the interface.
      Type Parameters:
      T - the rest client interface type
      Parameters:
      restClient - the interface to validate
      baseUrlOverride - the runtime base URL a relative method URL is validated against, or null to require @BaseUrl on the interface instead
      Throws:
      RestInPeaceValidationException - if any validation error is found