/** * 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 })); }
/** * 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 })); }
/** * 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 })); }
/** * Adds a default version to the version registry. This will overwrite any * existing default version for the same service. * * @param newDefault default version to add to the registry * (not <code>null</code>) * @param includeImplied if {@code true}, indicates that all implied versions * associated with the new default should be set as defaults too. */ public void addDefaultVersion(Version newDefault, boolean includeImplied) { // Implement the addition using a copy into a new array. This is done to // avoid requiring full synchronization of access to defaultVersions, where // additions will be infrequent and often happen at initialization time. ArrayList<Version> newDefaults = new ArrayList<Version>(defaultVersions); if (includeImplied) { mergeVersions(newDefaults, newDefault.getImpliedVersions()); } else { mergeVersions(newDefaults, newDefault); } // Replace the current defaults with the updated list. defaultVersions = Collections.unmodifiableList(newDefaults); }
/** * Adds a default version to the version registry. This will overwrite any * existing default version for the same service. * * @param newDefault default version to add to the registry * (not <code>null</code>) * @param includeImplied if {@code true}, indicates that all implied versions * associated with the new default should be set as defaults too. */ public void addDefaultVersion(Version newDefault, boolean includeImplied) { // Implement the addition using a copy into a new array. This is done to // avoid requiring full synchronization of access to defaultVersions, where // additions will be infrequent and often happen at initialization time. ArrayList<Version> newDefaults = new ArrayList<Version>(defaultVersions); if (includeImplied) { mergeVersions(newDefaults, newDefault.getImpliedVersions()); } else { mergeVersions(newDefaults, newDefault); } // Replace the current defaults with the updated list. defaultVersions = Collections.unmodifiableList(newDefaults); }
/** * Adds a default version to the version registry. This will overwrite any * existing default version for the same service. * * @param newDefault default version to add to the registry * (not <code>null</code>) * @param includeImplied if {@code true}, indicates that all implied versions * associated with the new default should be set as defaults too. */ public void addDefaultVersion(Version newDefault, boolean includeImplied) { // Implement the addition using a copy into a new array. This is done to // avoid requiring full synchronization of access to defaultVersions, where // additions will be infrequent and often happen at initialization time. ArrayList<Version> newDefaults = new ArrayList<Version>(defaultVersions); if (includeImplied) { mergeVersions(newDefaults, newDefault.getImpliedVersions()); } else { mergeVersions(newDefaults, newDefault); } // Replace the current defaults with the updated list. defaultVersions = Collections.unmodifiableList(newDefaults); }
/** * 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; }
/** * 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; }
/** * 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; }