From 1e7fa00ef463dd1c03eeedae7f859c480b7a3cf2 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 8 Mar 2016 17:47:17 +0000 Subject: [PATCH] Refactor --- source/net/filebot/Cache.java | 20 +++++++++---------- ...chedResource2.java => CachedResource.java} | 12 +++++------ source/net/filebot/web/OMDbClient.java | 2 +- source/net/filebot/web/TMDbClient.java | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) rename source/net/filebot/{CachedResource2.java => CachedResource.java} (88%) diff --git a/source/net/filebot/Cache.java b/source/net/filebot/Cache.java index 97affb12..603a60f4 100644 --- a/source/net/filebot/Cache.java +++ b/source/net/filebot/Cache.java @@ -1,7 +1,7 @@ package net.filebot; import static java.nio.charset.StandardCharsets.*; -import static net.filebot.CachedResource2.*; +import static net.filebot.CachedResource.*; import static net.filebot.Logging.*; import java.io.Serializable; @@ -10,7 +10,7 @@ import java.time.Duration; import java.util.Arrays; import java.util.function.Predicate; -import net.filebot.CachedResource2.Transform; +import net.filebot.CachedResource.Transform; import net.sf.ehcache.Element; import org.w3c.dom.Document; @@ -25,20 +25,20 @@ public class Cache { return CacheManager.getInstance().getCache(name, type); } - public CachedResource2 bytes(T key, Transform resource) { - return new CachedResource2(key, resource, fetchIfModified(), getBytes(), byte[].class::cast, ONE_DAY, this); + public CachedResource bytes(T key, Transform resource) { + return new CachedResource(key, resource, fetchIfModified(), getBytes(), byte[].class::cast, ONE_DAY, this); } - public CachedResource2 text(T key, Transform resource) { - return new CachedResource2(key, resource, fetchIfModified(), getText(UTF_8), String.class::cast, ONE_DAY, this); + public CachedResource text(T key, Transform resource) { + return new CachedResource(key, resource, fetchIfModified(), getText(UTF_8), String.class::cast, ONE_DAY, this); } - public CachedResource2 xml(T key, Transform resource) { - return new CachedResource2(key, resource, fetchIfModified(), validateXml(getText(UTF_8)), getXml(String.class::cast), ONE_DAY, this); + public CachedResource xml(T key, Transform resource) { + return new CachedResource(key, resource, fetchIfModified(), validateXml(getText(UTF_8)), getXml(String.class::cast), ONE_DAY, this); } - public CachedResource2 json(T key, Transform resource) { - return new CachedResource2(key, resource, fetchIfModified(), validateJson(getText(UTF_8)), getJson(String.class::cast), ONE_DAY, this); + public CachedResource json(T key, Transform resource) { + return new CachedResource(key, resource, fetchIfModified(), validateJson(getText(UTF_8)), getJson(String.class::cast), ONE_DAY, this); } private final net.sf.ehcache.Cache cache; diff --git a/source/net/filebot/CachedResource2.java b/source/net/filebot/CachedResource.java similarity index 88% rename from source/net/filebot/CachedResource2.java rename to source/net/filebot/CachedResource.java index c780bd89..cf0b9f8e 100644 --- a/source/net/filebot/CachedResource2.java +++ b/source/net/filebot/CachedResource.java @@ -18,7 +18,7 @@ import net.filebot.web.WebRequest; import org.w3c.dom.Document; -public class CachedResource2 implements Resource { +public class CachedResource implements Resource { public static final int DEFAULT_RETRY_LIMIT = 2; public static final Duration DEFAULT_RETRY_DELAY = Duration.ofSeconds(2); @@ -37,11 +37,11 @@ public class CachedResource2 implements Resource { private final Cache cache; - public CachedResource2(K key, Transform resource, Fetch fetch, Transform parse, Transform cast, Duration expirationTime, Cache cache) { + public CachedResource(K key, Transform resource, Fetch fetch, Transform parse, Transform cast, Duration expirationTime, Cache cache) { this(key, resource, fetch, parse, cast, DEFAULT_RETRY_LIMIT, DEFAULT_RETRY_DELAY, expirationTime, cache); } - public CachedResource2(K key, Transform resource, Fetch fetch, Transform parse, Transform cast, int retryLimit, Duration retryWait, Duration expirationTime, Cache cache) { + public CachedResource(K key, Transform resource, Fetch fetch, Transform parse, Transform cast, int retryLimit, Duration retryWait, Duration expirationTime, Cache cache) { this.key = key; this.resource = resource; this.fetch = fetch; @@ -53,17 +53,17 @@ public class CachedResource2 implements Resource { this.cache = cache; } - public synchronized CachedResource2 fetch(Fetch fetch) { + public synchronized CachedResource fetch(Fetch fetch) { this.fetch = fetch; return this; } - public synchronized CachedResource2 expire(Duration expirationTime) { + public synchronized CachedResource expire(Duration expirationTime) { this.expirationTime = expirationTime; return this; } - public synchronized CachedResource2 retry(int retryLimit) { + public synchronized CachedResource retry(int retryLimit) { this.retryLimit = retryLimit; return this; } diff --git a/source/net/filebot/web/OMDbClient.java b/source/net/filebot/web/OMDbClient.java index 9f0f56cd..5abfc73d 100644 --- a/source/net/filebot/web/OMDbClient.java +++ b/source/net/filebot/web/OMDbClient.java @@ -2,7 +2,7 @@ package net.filebot.web; import static java.util.Collections.*; import static java.util.stream.Collectors.*; -import static net.filebot.CachedResource2.*; +import static net.filebot.CachedResource.*; import static net.filebot.Logging.*; import static net.filebot.util.JsonUtilities.*; import static net.filebot.util.StringUtilities.*; diff --git a/source/net/filebot/web/TMDbClient.java b/source/net/filebot/web/TMDbClient.java index 556d64cd..1eee5720 100644 --- a/source/net/filebot/web/TMDbClient.java +++ b/source/net/filebot/web/TMDbClient.java @@ -3,7 +3,7 @@ package net.filebot.web; import static java.util.Arrays.*; import static java.util.Collections.*; import static java.util.stream.Collectors.*; -import static net.filebot.CachedResource2.*; +import static net.filebot.CachedResource.*; import static net.filebot.Logging.*; import static net.filebot.util.JsonUtilities.*; import static net.filebot.util.StringUtilities.*;