content: /**
    * Copyright 2017 JessYan
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    *      http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
  package <%= appPackage %>.di.module;
  
  import android.app.Application;
  import android.content.Context;
  import android.support.annotation.Nullable;
  
  import com.google.gson.Gson;
  import com.google.gson.GsonBuilder;
  import <%= appPackage %>.integration.IRepositoryManager;
  import <%= appPackage %>.integration.RepositoryManager;
  import <%= appPackage %>.integration.cache.Cache;
  import <%= appPackage %>.integration.cache.CacheType;
  
  import javax.inject.Singleton;
  
  import dagger.Module;
  import dagger.Provides;
  
  /**
   * ================================================
   * 提供一些框架必须的实例的 {@link Module}
   * <p>
   * Created by JessYan on 8/4/2016.
   * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
   * <a href="https://github.com/JessYanCoding">Follow me</a>
   * ================================================
   */
  @Module
  public class AppModule {
      private Application mApplication;
  
      public AppModule(Application application) {
          this.mApplication = application;
      }
  
      @Singleton
      @Provides
      public Application provideApplication() {
          return mApplication;
      }
  
      @Singleton
      @Provides
      public Gson provideGson(Application application, @Nullable GsonConfiguration configuration) {
          GsonBuilder builder = new GsonBuilder();
          if (configuration != null)
              configuration.configGson(application, builder);
          return builder.create();
      }
  
      @Singleton
      @Provides
      public IRepositoryManager provideRepositoryManager(RepositoryManager repositoryManager) {
          return repositoryManager;
      }
  
      @Singleton
      @Provides
      public Cache<String, Object> provideExtras(Cache.Factory cacheFactory) {
          return cacheFactory.build(CacheType.EXTRAS);
      }
  
      public interface GsonConfiguration {
          void configGson(Context context, GsonBuilder builder);
      }
  
  }
  