public InternalDependencyResult read(Decoder decoder, Map<ComponentSelector, ModuleVersionResolveException> failures) throws IOException {
ComponentSelector requested = componentSelectorSerializer.read(decoder);
byte resultByte = decoder.readByte();
if (resultByte == SUCCESSFUL) {
ModuleVersionIdentifier selected = moduleVersionIdentifierSerializer.read(decoder);
return new DefaultInternalDependencyResult(requested, selected, null, null);
} else if (resultByte == FAILED) {
ComponentSelectionReason reason = componentSelectionReasonSerializer.read(decoder);
ModuleVersionResolveException failure = failures.get(requested);
return new DefaultInternalDependencyResult(requested, null, reason, failure);