Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Added @nonnull annotation to improve error controll
Browse files Browse the repository at this point in the history
  • Loading branch information
iagocanalejas committed Jan 12, 2017
1 parent b10401c commit 75ac83f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.andiag.retrocache.cache.RetroCache;
import com.andiag.retrocache.interfaces.CachedCall;
Expand All @@ -23,7 +24,7 @@ public class CachedCallFactory extends CallAdapter.Factory {
private final Cache<String, byte[]> mCachingSystem;
private final Executor mAsyncExecutor;

public CachedCallFactory(Context context, int appVersion) {
public CachedCallFactory(@NonNull Context context, int appVersion) {
this.mCachingSystem = RetroCache.getDualCache(context, appVersion);
this.mAsyncExecutor = new Executor() {
@Override
Expand All @@ -33,7 +34,7 @@ public void execute(@NonNull Runnable command) {
};
}

public CachedCallFactory(Cache<String, byte[]> cachingSystem) {
public CachedCallFactory(@NonNull Cache<String, byte[]> cachingSystem) {
this.mCachingSystem = cachingSystem;
this.mAsyncExecutor = new Executor() {
@Override
Expand All @@ -43,7 +44,8 @@ public void execute(@NonNull Runnable command) {
};
}

public CachedCallFactory(Cache<String, byte[]> cachingSystem, Executor executor) {
public CachedCallFactory(@NonNull Cache<String, byte[]> cachingSystem,
@Nullable Executor executor) {
this.mCachingSystem = cachingSystem;
this.mAsyncExecutor = executor;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.andiag.retrocache.cache;

import android.content.Context;
import android.support.annotation.NonNull;

import com.andiag.retrocache.utils.ByteArraySerializer;
import com.andiag.retrocache.utils.EntryCountSizeOf;
Expand Down Expand Up @@ -38,14 +39,16 @@ public static DualCache<String, byte[]> getRamCache(int appVersion) {
* @param appVersion used to invalidate the cache.
* @return {@link DualCache}.
*/
public static DualCache<String, byte[]> getDualCache(Context context, int appVersion) {
public static DualCache<String, byte[]> getDualCache(@NonNull Context context, int appVersion) {
return new Builder<String, byte[]>(CACHE_NAME, appVersion)
.useReferenceInRam(REASONABLE_MEM_ENTRIES, new EntryCountSizeOf())
.useSerializerInDisk(REASONABLE_DISK_SIZE, true, new ByteArraySerializer(), context)
.build();
}

public static DualCache<String, byte[]> getVolatileCache(Context context, int appVersion) {
public static DualCache<String, byte[]> getVolatileCache(@NonNull Context context,
int appVersion) {

return new Builder<String, byte[]>(CACHE_NAME, appVersion)
.useReferenceInRam(REASONABLE_MEM_ENTRIES, new EntryCountSizeOf())
.useSerializerInDisk(REASONABLE_DISK_SIZE, true, new ByteArraySerializer(), context)
Expand Down

0 comments on commit 75ac83f

Please sign in to comment.