ComputationTarget result = isDeep ? _frontTargetCacheDeep.get(versionCorrection, specification) : _frontTargetCache.get(specification);
if (result != null) {
return result;
}
final UniqueId uid = specification.getUniqueId();
UniqueIdentifiable target = isDeep ? _frontObjectCacheDeep.get(versionCorrection, uid) : _frontObjectCache.get(uid);
if (target != null) {
// The cached object may be from an earlier lookup with a different resolution strategy. For example
// CTSpec[PRIMITIVE, Foo~Bar] will store the UniqueId object in the cache which is not suitable to
// return for CTSpec[SECURITY, Foo~Bar].
if (specification.getType().isCompatible(target)) {
result = ComputationTargetResolverUtils.createResolvedTarget(specification, target);
final ComputationTarget newResult = isDeep ? _frontTargetCacheDeep.putIfAbsent(versionCorrection, specification, result) : _frontTargetCache.putIfAbsent(specification, result);
if (newResult != null) {
return newResult;
} else {
return result;
}
}
}
final Object key = isDeep ? Pair.of(uid, versionCorrection) : uid;
final Element e = _computationTarget.get(key);
if (e != null) {
target = (UniqueIdentifiable) e.getObjectValue();
if (specification.getType().isCompatible(target)) {
final UniqueIdentifiable existing = isDeep ? _frontObjectCacheDeep.putIfAbsent(versionCorrection, uid, target) : _frontObjectCache.putIfAbsent(uid, target);
if (existing != null) {
result = ComputationTargetResolverUtils.createResolvedTarget(specification, existing);
} else {
result = ComputationTargetResolverUtils.createResolvedTarget(specification, target);
}
final ComputationTarget newResult = isDeep ? _frontTargetCacheDeep.putIfAbsent(versionCorrection, specification, result) : _frontTargetCache.put(specification, result);
if (newResult != null) {
return newResult;
} else {
return result;
}
}
}
result = super.resolve(specification, versionCorrection);
if (result != null) {
final UniqueIdentifiable existing = isDeep ? _frontObjectCacheDeep.putIfAbsent(versionCorrection, uid, result.getValue()) : _frontObjectCache.putIfAbsent(uid, result.getValue());
if (existing == null) {
addToCacheImpl(key, result.getValue());
}
final ComputationTarget newResult = isDeep ? _frontTargetCacheDeep.putIfAbsent(versionCorrection, specification, result) : _frontTargetCache.putIfAbsent(specification, result);
if (newResult != null) {