JAL-4152 Remove redundant casts from getInstance usages.
[jalview.git] / src / jalview / io / cache / AppCache.java
index 091d30e..65acd9c 100644 (file)
@@ -1,6 +1,27 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.io.cache;
 
-
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
 import jalview.bin.Cache;
 
 import java.util.Hashtable;
@@ -12,24 +33,27 @@ import java.util.LinkedHashSet;
  * @author tcnofoegbu
  *
  */
-public class AppCache
+public class AppCache implements ApplicationSingletonI
 {
-  public static final String DEFAULT_LIMIT = "99";
 
-  public static final String CACHE_DELIMITER = ";";
+  public static AppCache getInstance()
+  {
+    return ApplicationSingletonProvider.getInstance(AppCache.class);
+  }
 
-  private static AppCache instance = null;
+  private AppCache()
+  {
+    cacheItems = new Hashtable<String, LinkedHashSet<String>>();
+  }
 
-  private static final String DEFAULT_LIMIT_KEY = ".DEFAULT_LIMIT";
+  public static final String DEFAULT_LIMIT = "99";
 
+  public static final String CACHE_DELIMITER = ";";
 
+  private static final String DEFAULT_LIMIT_KEY = ".DEFAULT_LIMIT";
 
   private Hashtable<String, LinkedHashSet<String>> cacheItems;
 
-  private AppCache()
-  {
-    cacheItems = new Hashtable<String, LinkedHashSet<String>>();
-  }
 
   /**
    * Method to obtain all the cache items for a given cache key
@@ -48,23 +72,6 @@ public class AppCache
     return foundCache;
   }
 
-
-  /**
-   * Returns a singleton instance of AppCache
-   * 
-   * @return
-   */
-  public static AppCache getInstance()
-  {
-    if (instance == null)
-    {
-      instance = new AppCache();
-    }
-    return instance;
-  }
-
-
-
   /**
    * Method for persisting cache items for a given cache key
    *