/** * Takes a list of {@link Version} instances and merges it into another * list. A version in the source list will overwrite any value for the * same service (if any) in the target list. * @param target the target list of versions to merge into. * @param source the source list of versions that will be merged. */ @VisibleForTesting static void mergeVersions(List<Version> target, List<Version> source) { // Check for conflicts with target list before making any changes, // accumulating the list of changed versions. for (Version checkVersion : source) { Version currentVersion = Version.findServiceVersion(target, checkVersion.getServiceClass()); if (currentVersion != null) { target.remove(currentVersion); } } // Add all of the new versions. target.addAll(source); }
/** * Takes a list of {@link Version} instances and merges it into another * list. A version in the source list will overwrite any value for the * same service (if any) in the target list. * @param target the target list of versions to merge into. * @param source the source list of versions that will be merged. */ @VisibleForTesting static void mergeVersions(List<Version> target, List<Version> source) { // Check for conflicts with target list before making any changes, // accumulating the list of changed versions. for (Version checkVersion : source) { Version currentVersion = Version.findServiceVersion(target, checkVersion.getServiceClass()); if (currentVersion != null) { target.remove(currentVersion); } } // Add all of the new versions. target.addAll(source); }
/** * Takes a list of {@link Version} instances and merges it into another * list. A version in the source list will overwrite any value for the * same service (if any) in the target list. * @param target the target list of versions to merge into. * @param source the source list of versions that will be merged. */ @VisibleForTesting static void mergeVersions(List<Version> target, List<Version> source) { // Check for conflicts with target list before making any changes, // accumulating the list of changed versions. for (Version checkVersion : source) { Version currentVersion = Version.findServiceVersion(target, checkVersion.getServiceClass()); if (currentVersion != null) { target.remove(currentVersion); } } // Add all of the new versions. target.addAll(source); }
List<Version> threadList = getThreadVersions(); if (threadList != null) { v = Version.findServiceVersion(threadList, serviceClass); v = Version.findServiceVersion(getDefaultVersions(), serviceClass); if (v == null) {
List<Version> threadList = getThreadVersions(); if (threadList != null) { v = Version.findServiceVersion(threadList, serviceClass); v = Version.findServiceVersion(getDefaultVersions(), serviceClass); if (v == null) {
List<Version> threadList = getThreadVersions(); if (threadList != null) { v = Version.findServiceVersion(threadList, serviceClass); v = Version.findServiceVersion(getDefaultVersions(), serviceClass); if (v == null) {
/** * Returns {@code true} if this version is a earlier version than the * argument, on the basis of comparing the major and minor versions. For the * purposes of comparison, a value of {@link #ANY} is considered to be * {@link Integer#MIN_VALUE}, so no finite version number may come before it. * * @param v version to compare against * @return {@code true} if this version is later than the argument * @throws IllegalArgumentException if the provided version is not for the * same service as this version or for one implied by this version. */ public final boolean isBefore(Version v) { Version serviceVersion = findServiceVersion(impliedVersions, v.getServiceClass()); Preconditions.checkArgument(serviceVersion != null, "No relationship between versions"); // No need to normalize the value of ANY here, since it's value (-1) // is already less than all concrete versions if (serviceVersion.major != v.major) { return serviceVersion.major < v.major; } else { return serviceVersion.minor < v.minor; } }
/** * Returns {@code true} if this version is a earlier version than the * argument, on the basis of comparing the major and minor versions. For the * purposes of comparison, a value of {@link #ANY} is considered to be * {@link Integer#MIN_VALUE}, so no finite version number may come before it. * * @param v version to compare against * @return {@code true} if this version is later than the argument * @throws IllegalArgumentException if the provided version is not for the * same service as this version or for one implied by this version. */ public final boolean isBefore(Version v) { Version serviceVersion = findServiceVersion(impliedVersions, v.getServiceClass()); Preconditions.checkArgument(serviceVersion != null, "No relationship between versions"); // No need to normalize the value of ANY here, since it's value (-1) // is already less than all concrete versions if (serviceVersion.major != v.major) { return serviceVersion.major < v.major; } else { return serviceVersion.minor < v.minor; } }
/** * Returns {@code true} if this version is a earlier version than the * argument, on the basis of comparing the major and minor versions. For the * purposes of comparison, a value of {@link #ANY} is considered to be * {@link Integer#MIN_VALUE}, so no finite version number may come before it. * * @param v version to compare against * @return {@code true} if this version is later than the argument * @throws IllegalArgumentException if the provided version is not for the * same service as this version or for one implied by this version. */ public final boolean isBefore(Version v) { Version serviceVersion = findServiceVersion(impliedVersions, v.getServiceClass()); Preconditions.checkArgument(serviceVersion != null, "No relationship between versions"); // No need to normalize the value of ANY here, since it's value (-1) // is already less than all concrete versions if (serviceVersion.major != v.major) { return serviceVersion.major < v.major; } else { return serviceVersion.minor < v.minor; } }
/** * Returns {@code true} if this version is a later version than the argument, * on the basis of comparing the major and minor versions. For the purposes of * comparison, a value of {@link #ANY} is considered to be * {@link Integer#MAX_VALUE}, so no finite version number may come after it. * * @param v version to compare against * @return {@code true} if this version is later than the argument * @throws IllegalArgumentException if the provided version is not for the * same service as this version or for one implied by this version. */ public final boolean isAfter(Version v) { Version serviceVersion = findServiceVersion(impliedVersions, v.getServiceClass()); Preconditions.checkArgument(serviceVersion != null, "No relationship between versions"); int serviceMajor = raiseAny(serviceVersion.major); int vMajor = raiseAny(v.major); if (serviceMajor != vMajor) { return serviceMajor > vMajor; } else { return raiseAny(serviceVersion.minor) > raiseAny(v.minor); } }
/** * Returns {@code true} if this version is a later version than the argument, * on the basis of comparing the major and minor versions. For the purposes of * comparison, a value of {@link #ANY} is considered to be * {@link Integer#MAX_VALUE}, so no finite version number may come after it. * * @param v version to compare against * @return {@code true} if this version is later than the argument * @throws IllegalArgumentException if the provided version is not for the * same service as this version or for one implied by this version. */ public final boolean isAfter(Version v) { Version serviceVersion = findServiceVersion(impliedVersions, v.getServiceClass()); Preconditions.checkArgument(serviceVersion != null, "No relationship between versions"); int serviceMajor = raiseAny(serviceVersion.major); int vMajor = raiseAny(v.major); if (serviceMajor != vMajor) { return serviceMajor > vMajor; } else { return raiseAny(serviceVersion.minor) > raiseAny(v.minor); } }
/** * Returns {@code true} if this version is a later version than the argument, * on the basis of comparing the major and minor versions. For the purposes of * comparison, a value of {@link #ANY} is considered to be * {@link Integer#MAX_VALUE}, so no finite version number may come after it. * * @param v version to compare against * @return {@code true} if this version is later than the argument * @throws IllegalArgumentException if the provided version is not for the * same service as this version or for one implied by this version. */ public final boolean isAfter(Version v) { Version serviceVersion = findServiceVersion(impliedVersions, v.getServiceClass()); Preconditions.checkArgument(serviceVersion != null, "No relationship between versions"); int serviceMajor = raiseAny(serviceVersion.major); int vMajor = raiseAny(v.major); if (serviceMajor != vMajor) { return serviceMajor > vMajor; } else { return raiseAny(serviceVersion.minor) > raiseAny(v.minor); } }