JAL-3253 ApplicationSingletonProvider replaces Instance
[jalview.git] / src / jalview / ws / sifts / SiftsSettings.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.ws.sifts;
22
23 import jalview.bin.ApplicationSingletonProvider;
24 import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
25
26 import java.util.Objects;
27
28 public class SiftsSettings implements ApplicationSingletonI
29 {
30
31   /**
32    * public only for testng
33    * 
34    * @return
35    */
36   public static SiftsSettings getInstance()
37   {
38     return (SiftsSettings) ApplicationSingletonProvider
39             .getInstance(SiftsSettings.class);
40   }
41
42   private SiftsSettings()
43   {
44     // singleton; use getInstance()
45   }
46
47   private boolean mapWithSifts = false;
48
49   private String siftDownloadDirectory;
50
51   private int cacheThresholdInDays;
52
53   private int failSafePIDThreshold;
54
55   public static boolean isMapWithSifts()
56   {
57     return getInstance().mapWithSifts;
58   }
59
60   public static void setMapWithSifts(boolean mapWithSifts)
61   {
62     getInstance().mapWithSifts = mapWithSifts;
63   }
64
65   public static String getSiftDownloadDirectory()
66   {
67     return getInstance().siftDownloadDirectory;
68   }
69
70   public static void setSiftDownloadDirectory(String siftDownloadDirectory)
71   {
72     getInstance().siftDownloadDirectory = siftDownloadDirectory;
73   }
74
75   public static int getCacheThresholdInDays()
76   {
77     return getInstance().cacheThresholdInDays;
78   }
79
80   public static void setCacheThresholdInDays(String cacheThresholdInDays)
81   {
82     Objects.requireNonNull(cacheThresholdInDays);
83     getInstance().cacheThresholdInDays = Integer
84             .valueOf(cacheThresholdInDays);
85   }
86
87   public static int getFailSafePIDThreshold()
88   {
89     return getInstance().failSafePIDThreshold;
90   }
91
92   public static void setFailSafePIDThreshold(String failSafePIDThreshold)
93   {
94     Objects.requireNonNull(failSafePIDThreshold);
95     getInstance().failSafePIDThreshold = Integer
96             .valueOf(failSafePIDThreshold);
97   }
98 }