private synchronized void ensureRecentLocations() { if (recentLocations == null) { recentLocations = new RecentQueue<String>(MAX_RECENT); } }
private synchronized void ensureRecents() { if (recents == null) { recents = new RecentQueue<TimesheetPrefEntry>(MAX_RECENT); } }
private synchronized void ensureRecentTasks() { if (recentTasks == null) { recentTasks = new RecentQueue<Integer>(MAX_RECENT); } }
public RecentScriptCalls() { recentQueue = new RecentQueue<ScriptCallData>(); }
@SuppressWarnings("unchecked") private RecentQueue<String> getRecentProjects() { if (this.recentProjects == null) { this.recentProjects = (RecentQueue<String>) UserPreferencesHelper.getEntry(USER_PREF_KEY_RECENT_PROJECTS); } if (this.recentProjects == null) { this.recentProjects = new RecentQueue<String>(); UserPreferencesHelper.putEntry(USER_PREF_KEY_RECENT_PROJECTS, this.recentProjects, true); } return this.recentProjects; }
@SuppressWarnings("unchecked") private RecentQueue<String> getRecentEmployees() { if (this.recentEmployees == null) { this.recentEmployees = (RecentQueue<String>) UserPreferencesHelper.getEntry(USER_PREF_KEY_RECENT_EMPLOYEES); } if (this.recentEmployees == null) { this.recentEmployees = new RecentQueue<String>(); UserPreferencesHelper.putEntry(USER_PREF_KEY_RECENT_EMPLOYEES, this.recentEmployees, true); } return this.recentEmployees; }
@SuppressWarnings("unchecked") private RecentQueue<String> getRecentTrainings() { if (this.recentTrainings == null) { this.recentTrainings = (RecentQueue<String>) UserPreferencesHelper.getEntry(USER_PREF_KEY_RECENT_TRAININGS); } if (this.recentTrainings == null) { this.recentTrainings = new RecentQueue<String>(); UserPreferencesHelper.putEntry(USER_PREF_KEY_RECENT_TRAININGS, this.recentTrainings, true); } return this.recentTrainings; }
@SuppressWarnings("unchecked") private RecentQueue<String> getRecentSkills() { if (this.recentSkills == null) { this.recentSkills = (RecentQueue<String>) UserPreferencesHelper.getEntry(USER_PREF_KEY_RECENT_SKILLS); } if (this.recentSkills == null) { this.recentSkills = new RecentQueue<String>(); UserPreferencesHelper.putEntry(USER_PREF_KEY_RECENT_SKILLS, this.recentSkills, true); } return this.recentSkills; }
@SuppressWarnings("unchecked") private RecentQueue<String> getRecentUsers() { if (this.recentUsers == null) { this.recentUsers = (RecentQueue<String>) UserPreferencesHelper.getEntry(USER_PREF_KEY_RECENT_USERS); } if (this.recentUsers == null) { this.recentUsers = new RecentQueue<String>(); UserPreferencesHelper.putEntry(USER_PREF_KEY_RECENT_USERS, this.recentUsers, true); } return this.recentUsers; }
@SuppressWarnings("unchecked") private RecentQueue<String> getRecentCustomers() { if (this.recentGroups == null) { this.recentGroups = (RecentQueue<String>) UserPreferencesHelper.getEntry(USER_PREF_KEY_RECENT_GROUPS); } if (this.recentGroups == null) { this.recentGroups = new RecentQueue<String>(); UserPreferencesHelper.putEntry(USER_PREF_KEY_RECENT_GROUPS, this.recentGroups, true); } return this.recentGroups; }
@SuppressWarnings("unchecked") private RecentQueue<String> getRecentCustomers() { if (this.recentCustomers == null) { this.recentCustomers = (RecentQueue<String>) UserPreferencesHelper.getEntry(USER_PREF_KEY_RECENT_CUSTOMERS); } if (this.recentCustomers == null) { this.recentCustomers = new RecentQueue<String>(); UserPreferencesHelper.putEntry(USER_PREF_KEY_RECENT_CUSTOMERS, this.recentCustomers, true); } return this.recentCustomers; }
@SuppressWarnings("unchecked") protected RecentQueue<String> getRecentSearchTermsQueue() { if (recentSearchTermsQueue == null) { recentSearchTermsQueue = (RecentQueue<String>) parentPage.getUserPrefEntry(USER_PREF_KEY_RECENTS); } if (recentSearchTermsQueue == null) { recentSearchTermsQueue = (RecentQueue<String>) parentPage .getUserPrefEntry(this.getClass().getName() + ":recentSearchTerms"); if (recentSearchTermsQueue != null) { // Old entries: parentPage.putUserPrefEntry(USER_PREF_KEY_RECENTS, recentSearchTermsQueue, true); parentPage.removeUserPrefEntry(this.getClass().getName() + ":recentSearchTerms"); } } if (recentSearchTermsQueue == null) { recentSearchTermsQueue = new RecentQueue<String>(); parentPage.putUserPrefEntry(USER_PREF_KEY_RECENTS, recentSearchTermsQueue, true); } return recentSearchTermsQueue; }
@SuppressWarnings("unchecked") public RecentQueue<String> getRecentSearchTermsQueue() { if (recentSearchTermsQueue == null) { recentSearchTermsQueue = (RecentQueue<String>) getUserPrefEntry(this.recentSearchTermsUserPrefKey); } if (recentSearchTermsQueue == null) { recentSearchTermsQueue = new RecentQueue<String>(); if (isRecentSearchTermsStorage() == true) { putUserPrefEntry(this.recentSearchTermsUserPrefKey, recentSearchTermsQueue, true); } } return recentSearchTermsQueue; }
@SuppressWarnings("unchecked") protected RecentQueue<String> getRecentSearchTermsQueue() { if (recentSearchTermsQueue == null) { recentSearchTermsQueue = (RecentQueue<String>) parentPage.getUserPrefEntry(USER_PREF_KEY_RECENTS); } if (recentSearchTermsQueue == null) { recentSearchTermsQueue = (RecentQueue<String>) parentPage .getUserPrefEntry("org.projectforge.web.address.PhoneCallAction:recentSearchTerms"); if (recentSearchTermsQueue != null) { // Old entries: parentPage.putUserPrefEntry(USER_PREF_KEY_RECENTS, recentSearchTermsQueue, true); parentPage.removeUserPrefEntry("org.projectforge.web.address.PhoneCallAction:recentSearchTerms"); } } if (recentSearchTermsQueue == null) { recentSearchTermsQueue = new RecentQueue<String>(); parentPage.putUserPrefEntry(USER_PREF_KEY_RECENTS, recentSearchTermsQueue, true); } return recentSearchTermsQueue; } }
@Test public void test() { RecentQueue<Integer> queue = new RecentQueue<Integer>(4); assertEquals("Length of queue", 0, queue.size()); assertNull(queue.get(null)); assertNull(queue.get(5)); assertNull(queue.get(-1)); checkQueue(queue); queue.append(4); checkQueue(queue, 4); queue.append(4); checkQueue(queue, 4); queue.append(3).append(2); checkQueue(queue, 2, 3, 4); queue.append(4); checkQueue(queue, 4, 2, 3); queue.append(3).append(2); checkQueue(queue, 2, 3, 4); queue.append(1); checkQueue(queue, 1, 2, 3, 4); queue.append(0); checkQueue(queue, 0, 1, 2, 3); queue.append(3); checkQueue(queue, 3, 0, 1, 2); assertEquals(new Integer(3), queue.get(null)); assertNull(queue.get(5)); assertNull(queue.get(-1)); }