// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
// 
//   Single<V> get(K key);
// 
//   Single<V> put(K key, V value, long expiry, TimeUnit unit);
// 
//   Single<K> remove(K key);
// 
//   Single<Map<K, V>> getAll(Collection<K> keys);
// 
//   Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
// 
//   Single<Collection<K>> removeAll(Collection<K> keys);
// 
// }
// 
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
// 
//   String toString(T model);
// 
//   T fromString(String str);
// }
// 
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
// 
//   void write(Object value, OutputStream out) throws SerializerException;
// 
//   <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
// 
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/VersionMapper.java
// public interface VersionMapper<T> {
// 
//   public static final Long UNVERSIONED = -1L;
// 
//   long getVersion(T model);
// }
// 
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/version/NoOpVersionMapper.java
// public class NoOpVersionMapper<T> implements VersionMapper<T> {
// 
//   @Override public long getVersion(T model) {
//     return UNVERSIONED;
//   }
// }
// 
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
//   if (object == null) {
//     throw new IllegalArgumentException(message);
//   }
// 
//   return object;
// }


import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.mobilejazz.cacheio.RxCache;
import com.mobilejazz.cacheio.mappers.KeyMapper;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.mappers.VersionMapper;
import com.mobilejazz.cacheio.mappers.version.NoOpVersionMapper;
import rx.Single;
import rx.SingleSubscriber;
import rx.functions.Func1;
import java.io.*;
import java.util.*;
    public Builder<K, V> setValueMapper(ValueMapper valueMapper) {
      this.valueMapper = valueMapper;
      return this;
    }

    public Builder<K, V> setVersionMapper(VersionMapper<V> versionMapper) {
      this.versionMapper = versionMapper;
      return this;
    }

    private void removeExpired() {
      final long now = System.currentTimeMillis();
      db.execSQL(String.format(DELETE_EXPIRED_SQL, tableName), new Object[] { now });
    }

    @SuppressWarnings("unchecked") public RxCache<K, V> build() {

      // defaults

      if (this.tableName == null) {
        this.tableName = keyType.getName().replaceAll("\\.", "_") + "___" + valueType.getName()
            .replaceAll("\\.", "_");
      }

      if (this.versionMapper == null) {
        this.versionMapper = new NoOpVersionMapper<>();
      }

      // assertions

// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
// 
//   Single<V> get(K key);
// 
//   Single<V> put(K key, V value, long expiry, TimeUnit unit);
// 
//   Single<K> remove(K key);
// 
//   Single<Map<K, V>> getAll(Collection<K> keys);
// 
//   Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
// 
//   Single<Collection<K>> removeAll(Collection<K> keys);
// 
// }
// 
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
// 
//   String toString(T model);
// 
//   T fromString(String str);
// }
// 
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
// 
//   void write(Object value, OutputStream out) throws SerializerException;
// 
//   <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
// 
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/VersionMapper.java
// public interface VersionMapper<T> {
// 
//   public static final Long UNVERSIONED = -1L;
// 
//   long getVersion(T model);
// }
// 
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/version/NoOpVersionMapper.java
// public class NoOpVersionMapper<T> implements VersionMapper<T> {
// 
//   @Override public long getVersion(T model) {
//     return UNVERSIONED;
//   }
// }
// 
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
//   if (object == null) {
//     throw new IllegalArgumentException(message);
//   }
// 
//   return object;
// }


// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/caches/SQLiteRxCache.java
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.mobilejazz.cacheio.RxCache;
import com.mobilejazz.cacheio.mappers.KeyMapper;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.mappers.VersionMapper;
import com.mobilejazz.cacheio.mappers.version.NoOpVersionMapper;
import rx.Single;
import rx.SingleSubscriber;
import rx.functions.Func1;
import java.io.*;
import java.util.*;

    public Builder<K, V> setValueMapper(ValueMapper valueMapper) {
      this.valueMapper = valueMapper;
      return this;
    }

    public Builder<K, V> setVersionMapper(VersionMapper<V> versionMapper) {
      this.versionMapper = versionMapper;
      return this;
    }

    private void removeExpired() {
      final long now = System.currentTimeMillis();
      db.execSQL(String.format(DELETE_EXPIRED_SQL, tableName), new Object[] { now });
    }

    @SuppressWarnings("unchecked") public RxCache<K, V> build() {

      // defaults

      if (this.tableName == null) {
        this.tableName = keyType.getName().replaceAll("\\.", "_") + "___" + valueType.getName()
            .replaceAll("\\.", "_");
      }

      if (this.versionMapper == null) {
        this.versionMapper = new NoOpVersionMapper<>();
      }

      // assertions

      checkArgument(db, "Database cannot be null");