Given two candidates, return the more precise one. If no viable candidate,
return null;

@param candidate
The current best candidate.
@param next
The next candidate being considered
@param environment
@return
@throws ResolutionError
551901
public <T extends Type> T selectCandidate(T candidate, T next, T actual, Environment environment) {
		// Found a viable candidate
		boolean left = subtypeOperator.isSubtype(candidate, next, environment);
		boolean right = subtypeOperator.isSubtype(next, candidate, environment);
		if (left && !right) {
			// Yes, is better than current candidate
			return next;
		} else if (right && !left) {
			return candidate;
		}
		// Unable to distinguish options based on subtyping alone
		left = isDerivation(next, actual);
		right = isDerivation(candidate, actual);
		if (left && !right) {
			// Yes, is better than current candidate
			return next;
		} else if (right && !left) {
			return candidate;
		} else {
			return null;
		}

	}
1367205
public static EnvironmentDetail getEnvironmentDetail(final String application, final String environment) {
		
		// lookup the host name

		String hostName = getHostName();
		
		// lookup the current path
		
		String currentPath = System.getProperty("user.dir");
		
		// build the environment details
		
		EnvironmentDetail.Builder environmentBuilder = EnvironmentDetail.newBuilder();
		environmentBuilder.deviceName(hostName);
		environmentBuilder.appLocation(currentPath);
		environmentBuilder.configuredAppName(application);
		environmentBuilder.configuredEnvironmentName(environment);
		
		return environmentBuilder.build();
	}
1286058
private String resolveVarEnv(final String entryValue) {

        String value = entryValue;
        if (value != null) {
            value = checkPattern(value, ENV_VAR_PATTERN1, true);
            value = checkPattern(value, ENV_VAR_PATTERN2, false);
        }
        return value;
    }
566573
public EnvironmentFactoryBuilder withConfigResolver(EnvironmentConfigResolver configResolver) {
    checkState(!this.configResolver.isPresent(), "Configuration resolution already set");

    return new EnvironmentFactoryBuilder(backendDomain, client, closer, resolver,
                                         Optional.of(configResolver));
  }
1207521
public ResourceAddress resolve(StatementContext context, List<String> wildcards) {
        Resolution<ModelNode> resolution = new Resolution<ModelNode>() {
             private ModelNode modelNode;

             @Override
             public void init() {
                 this.modelNode = new ModelNode();
             }

             @Override
             public void addKeyValue(String key, String value) {
                 this.modelNode.add(key, value);
             }

             @Override
             public ModelNode getResult() {
                 return modelNode;
             }
         };

         _resolve(context, wildcards, resolution);

         return new ResourceAddress(resolution.getResult());
    }
343782
protected @Nonnull <T> Collection<T> getBeansOfType(@Nullable BeanResolutionContext resolutionContext, @Nonnull Class<T> beanType) {
        return getBeansOfTypeInternal(resolutionContext, beanType, null);
    }
1333317
@Override
    public final STRATEGYSTAGETYPE resolve(final String coordinate) throws IllegalArgumentException {
        final MavenDependency dep = this.resolveDependency(coordinate);
        this.addDependency(dep);
        return this.resolve();
    }
1052907
protected T resolve(String sKey, T value) {
        LOG.error("Fail to find environment [{}] in {}", sKey, this.keySet());
        throw new MultiEnvSupportException(String.format(
                "Fail to find configuration for environment %s", sKey));
    }
558859
@SuppressWarnings({"unused", "unchecked"})
    @Internal
    protected final Object getValueForMethodArgument(BeanResolutionContext resolutionContext, BeanContext context, int methodIndex, int argIndex) {
        MethodInjectionPoint injectionPoint = methodInjectionPoints.get(methodIndex);
        Argument argument = injectionPoint.getArguments()[argIndex];
        BeanResolutionContext.Path path = resolutionContext.getPath();
        path.pushMethodArgumentResolve(this, injectionPoint, argument);
        if (context instanceof ApplicationContext) {
            // can't use orElseThrow here due to compiler bug
            try {
                String valueAnnStr = argument.getAnnotationMetadata().getValue(Value.class, String.class).orElse(null);
                Class argumentType = argument.getType();

                if (isInnerConfiguration(argumentType)) {
                    Qualifier qualifier = resolveQualifier(resolutionContext, argument, true);
                    return ((DefaultBeanContext) context).getBean(resolutionContext, argumentType, qualifier);
                } else {
                    String argumentName = argument.getName();
                    String valString = resolvePropertyValueName(resolutionContext, injectionPoint.getAnnotationMetadata(), argument, valueAnnStr);


                    ApplicationContext applicationContext = (ApplicationContext) context;
                    ArgumentConversionContext conversionContext = ConversionContext.of(argument);
                    Optional value = resolveValue(applicationContext, conversionContext, valueAnnStr != null, valString);
                    if (argumentType == Optional.class) {
                        return resolveOptionalObject(value);
                    } else {
                        if (value.isPresent()) {
                            return value.get();
                        } else {
                            if (argument.isDeclaredAnnotationPresent(Nullable.class)) {
                                return null;
                            }
                            throw new DependencyInjectionException(resolutionContext, injectionPoint, conversionContext, valString);
                        }
                    }
                }
            } finally {
                path.pop();
            }
        } else {
            path.pop();
            throw new DependencyInjectionException(resolutionContext, argument, "BeanContext must support property resolution");
        }
    }
886740
private Implementation.SpecialMethodInvocation invokeSuper(MethodRebaseResolver.Resolution resolution) {
        return resolution.isRebased()
                ? RebasedMethodInvocation.of(resolution.getResolvedMethod(), instrumentedType, resolution.getAdditionalArguments())
                : Implementation.SpecialMethodInvocation.Simple.of(resolution.getResolvedMethod(), instrumentedType);
    }
395845
public static void resolve(Map<String, String> env) {
		for (Map.Entry<String,String> entry: env.entrySet()) {
			entry.setValue(Util.replaceMacro(entry.getValue(), env));
		}
	}
1284352
@Override
	public int compare(ResourceGenerator o1, ResourceGenerator o2) {
		
		ResolverComparator rComparator = new ResolverComparator();
		return rComparator.compare(o1.getResolver(), o2.getResolver());
	}
51165
public int getResolutionIndex(double resolution) {
		double maximumResolution = getMaximumResolution();
		if (resolution >= maximumResolution) {
			return 0;
		}
		double minimumResolution = getMinimumResolution();
		if (resolution <= minimumResolution) {
			return resolutions.size() - 1;
		}

		for (int i = 0; i < resolutions.size(); i++) {
			double upper = resolutions.get(i);
			double lower = resolutions.get(i + 1);
			if (resolution < upper && resolution >= lower) {
				if (Math.abs(upper - resolution) >= Math.abs(lower - resolution)) {
					return i + 1;
				} else {
					return i;
				}
			}
		}
		return 0;
	}
1114366
@Pure
	public static Object getContextResolver() throws AndroidException {
		Object resolver;
		synchronized (Android.class) {
			resolver = (contextResolver == null) ? null : contextResolver.get();
		}
		if (resolver == null) {
			final Object context = getContext();
			try {
				final Class<?> resolverType = getContextResolverClass();
				final Class<?> contextType = context.getClass();
				final Method getContextResolverMethod = contextType.getMethod("getContentResolver"); //$NON-NLS-1$
				resolver = getContextResolverMethod.invoke(context);
				resolver = resolverType.cast(resolver);
				synchronized (Android.class) {
					contextResolver = new WeakReference<>(resolver);
				}
			} catch (AssertionError e) {
				throw e;
			} catch (Throwable e) {
				throw new AndroidException(e);
			}
		}
		return resolver;
	}
1205403
private Resolved resolve(Record record, ReadConsistency consistency) {
        return resolve(record, consistency, true);
    }
273306
protected Resolver getResolver()
        throws MojoExecutionException
    {
        List<File> catalogFiles = new ArrayList<File>();
        List<URL> catalogUrls = new ArrayList<URL>();
        setCatalogs( catalogFiles, catalogUrls );

        return new Resolver( getBasedir(), catalogFiles, catalogUrls, getLocator(), catalogHandling,getLog().isDebugEnabled() );
    }
510257
public static ObjectModelResolver get(String resolverId) {
        List<ObjectModelResolver> resolvers = getResolvers();

        for (ObjectModelResolver resolver : resolvers) {
            if (resolver.accept(resolverId)) {
                return resolver;
            }
        }

        return null;
    }