title: Service Generator Retrofit
body: <p>Can someone help me understand the <code>createService</code> method in below code. I need to understand what is method's parameter Class <code>S</code> and the code underneath in depth</p>
  
  <pre><code>public class ServiceGenerator {
  
  public static final String API_BASE_URL = Constant.BASE_URL;
  
  private static OkHttpClient httpClient = new OkHttpClient();
  
  private static Retrofit.Builder builder =
          new Retrofit.Builder()
                  .baseUrl(API_BASE_URL)
                  .addConverterFactory(GsonConverterFactory.create());
  
  public static &lt;S&gt; S createService(Class&lt;S&gt; serviceClass) {
      httpClient.interceptors().add(new Interceptor() {
          @Override
          public Response intercept(Chain chain) throws IOException {
              Request original = chain.request();
  
              Request.Builder requestBuilder = original.newBuilder()
                      .header("cache-control","no-cache")
                      .method(original.method(), original.body());
  
              Request request = requestBuilder.build();
              return chain.proceed(request);
          }
      });
  
      Retrofit retrofit = builder.client(httpClient).build();
      return retrofit.create(serviceClass);
  }
  </code></pre>
  
  <p>}</p>