Class Resource

  • Direct Known Subclasses:
    EpisodesAPI, LanguagesAPI, QueryResource

    public abstract class Resource
    extends Object
    General implementation for remote API resources.


    Provides general functionality for the creation of URL path parameter based resource strings.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static Predicate<Long> ID_VALIDATOR
      Validator for the common dynamic id URL path parameter
      protected static String PATH_ID
      Identifiers for common dynamic URL path parameters
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Resource()  
    • Field Detail

      • ID_VALIDATOR

        protected static final Predicate<Long> ID_VALIDATOR
        Validator for the common dynamic id URL path parameter
    • Constructor Detail

      • Resource

        protected Resource()
    • Method Detail

      • createResource

        protected static String createResource​(@Nonnull
                                               String base,
                                               Object... pathParams)
        Creates a new resource string consisting of the given base URL path parameter prepended by some optional route specific path parameters in the following format: /BASE/param1/param2/...
        Parameters:
        base - Base URL path parameter which identifies a particular endpoint
        pathParams - Optional additional path parameters to be prepended to the end of the resource string
        Returns:
        Composed resource String based on the given parameters
      • createResource

        protected static String createResource​(@Nonnull
                                               String base,
                                               @CheckForNull
                                               String specific,
                                               Object... pathParams)
        Creates a new resource string consisting of the given base and specific URL path parameters prepended by some optional additional route path parameters in the following format: /BASE/specific/param1/param2/...
        Parameters:
        base - Base URL path parameter which identifies a particular endpoint
        specific - Specific URL path parameter representing the actual route to be invoked
        pathParams - Optional additional path parameters to be prepended to the end of the resource string
        Returns:
        Composed resource String based on the given parameters