Adds additional constructor.
@@ -63,6 +63,31 @@ public final class ColoredImageCache {
.build();
}
+ /**
+ * Constructs a new ColoredImageCache.
+ *
+ * @param font
+ * The font.
+ *
+ * @param maxCacheSize
+ * The maximum number of images to save in the cache.
+ *
+ * @param expiryTimeInMinutes
+ * The length of time, in minutes, after an entry is last accessed
+ * that it should be automatically removed from the cache.
+ *
+ * @throws NullPointerException
+ * If the font is null.
+ */
+ public ColoredImageCache(final @NonNull Font font, final int maxCacheSize, final int expiryTimeInMinutes) {
+ this.font = font;
+ cachedImages = Caffeine.newBuilder()
+ .initialCapacity(256)
+ .maximumSize(maxCacheSize)
+ .expireAfterAccess(expiryTimeInMinutes, TimeUnit.MINUTES)
+ .build();
+ }
+
/**
* Retrieves a character image from the cache.
*
