/** * Returns the current GData version used by the Google Finance Portfolio Data * API. */ public static Version getVersion() { return VersionRegistry.get().getVersion(FinanceService.class); }
/** * Returns the current VersionRegistry, creating it if necessary. The * {@link #get()} method is preferred for most registry usage, as it enables * the discovery of the execution of version-conditional code in an * environment (such as unit test cases) where versioning has not been * properly configured. */ public static synchronized VersionRegistry ensureRegistry() { if (versionRegistry == null) { versionRegistry = new VersionRegistry(); } return versionRegistry; }
protected void endVersionScope() { VersionRegistry.get().resetThreadVersion(); }
protected void startVersionScope() { VersionRegistry.get().setThreadVersion(protocolVersion); }
Class<? extends Service> serviceClass, Version defaultVersion) { VersionRegistry versionRegistry = VersionRegistry.ensureRegistry(); Version v = null; try { v = versionRegistry.getVersion(serviceClass); } catch (IllegalStateException ise) { v = VersionRegistry.getVersionFromProperty(serviceClass); } catch (SecurityException e) { versionRegistry.addDefaultVersion(v, false);
/** * Returns the the current list of active versions. This list takes both * global defaults and thread versions into account. */ @VisibleForTesting List<Version> getVersions() { List<Version> defaultList = getDefaultVersions(); List<Version> threadList = getThreadVersions(); if (threadList == null) { return defaultList; } List<Version> combinedList = new ArrayList<Version>(defaultList.size() + threadList.size()); combinedList.addAll(defaultList); mergeVersions(combinedList, threadList); return combinedList; }
List<Version> threadList = getThreadVersions(); if (threadList != null) { v = Version.findServiceVersion(threadList, serviceClass); v = Version.findServiceVersion(getDefaultVersions(), serviceClass); if (v == null) {
/** * Takes a {@link Version} instance and merges it into another * list, validating that any duplicate information for a given service * is a compatible version. * @param target the target list of versions to merge into. * @param source the source version that will be merged. */ @VisibleForTesting static void mergeVersions(List<Version> target, Version source) { mergeVersions(target, Arrays.asList(new Version [] { source })); }
Class<? extends Service> serviceClass, Version defaultVersion) { VersionRegistry versionRegistry = VersionRegistry.ensureRegistry(); Version v = null; try { v = versionRegistry.getVersion(serviceClass); } catch (IllegalStateException ise) { v = VersionRegistry.getVersionFromProperty(serviceClass); } catch (SecurityException e) { versionRegistry.addDefaultVersion(v, false);
protected void startVersionScope() { VersionRegistry.get().setThreadVersion(protocolVersion); }
/** * Returns the the current list of active versions. This list takes both * global defaults and thread versions into account. */ @VisibleForTesting List<Version> getVersions() { List<Version> defaultList = getDefaultVersions(); List<Version> threadList = getThreadVersions(); if (threadList == null) { return defaultList; } List<Version> combinedList = new ArrayList<Version>(defaultList.size() + threadList.size()); combinedList.addAll(defaultList); mergeVersions(combinedList, threadList); return combinedList; }
List<Version> threadList = getThreadVersions(); if (threadList != null) { v = Version.findServiceVersion(threadList, serviceClass); v = Version.findServiceVersion(getDefaultVersions(), serviceClass); if (v == null) {
/** * Takes a {@link Version} instance and merges it into another * list, validating that any duplicate information for a given service * is a compatible version. * @param target the target list of versions to merge into. * @param source the source version that will be merged. */ @VisibleForTesting static void mergeVersions(List<Version> target, Version source) { mergeVersions(target, Arrays.asList(new Version [] { source })); }
/** * Returns the current GData version used by the Google Contacts service. */ public static Version getVersion() { return VersionRegistry.get().getVersion(ContactsService.class); }
Class<? extends Service> serviceClass, Version defaultVersion) { VersionRegistry versionRegistry = VersionRegistry.ensureRegistry(); Version v = null; try { v = versionRegistry.getVersion(serviceClass); } catch (IllegalStateException ise) { v = VersionRegistry.getVersionFromProperty(serviceClass); } catch (SecurityException e) { versionRegistry.addDefaultVersion(v, false);
protected void startVersionScope() { VersionRegistry.get().setThreadVersion(protocolVersion); }
protected void endVersionScope() { VersionRegistry.get().resetThreadVersion(); }
/** * Returns the the current list of active versions. This list takes both * global defaults and thread versions into account. */ @VisibleForTesting List<Version> getVersions() { List<Version> defaultList = getDefaultVersions(); List<Version> threadList = getThreadVersions(); if (threadList == null) { return defaultList; } List<Version> combinedList = new ArrayList<Version>(defaultList.size() + threadList.size()); combinedList.addAll(defaultList); mergeVersions(combinedList, threadList); return combinedList; }
List<Version> threadList = getThreadVersions(); if (threadList != null) { v = Version.findServiceVersion(threadList, serviceClass); v = Version.findServiceVersion(getDefaultVersions(), serviceClass); if (v == null) {
/** * Takes a {@link Version} instance and merges it into another * list, validating that any duplicate information for a given service * is a compatible version. * @param target the target list of versions to merge into. * @param source the source version that will be merged. */ @VisibleForTesting static void mergeVersions(List<Version> target, Version source) { mergeVersions(target, Arrays.asList(new Version [] { source })); }