package jetbrains.mps.internal.make.runtime.script;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import jetbrains.mps.make.script.IResult;
import java.util.Map;
import jetbrains.mps.make.facet.ITarget;
import jetbrains.mps.internal.collections.runtime.MapSequence;
import java.util.LinkedHashMap;
import jetbrains.mps.internal.collections.runtime.Sequence;
import jetbrains.mps.make.resources.IResource;

@GeneratedClass(node = "r:8e0d2787-667a-41b8-9f98-9bb45c087fba(jetbrains.mps.internal.make.runtime.script)/1291978361072214390", model = "r:8e0d2787-667a-41b8-9f98-9bb45c087fba(jetbrains.mps.internal.make.runtime.script)")
public class CompositeResult implements IResult {
  private Map<ITarget.Name, IResult> results = MapSequence.fromMap(new LinkedHashMap<ITarget.Name, IResult>(16, (float) 0.75, false));
  public CompositeResult() {
  }
  public void addResult(ITarget.Name target, IResult res) {
    MapSequence.fromMap(results).put(target, res);
  }
  public IResult getResult(ITarget.Name target) {
    return MapSequence.fromMap(results).get(target);
  }
  @Override
  public boolean isSucessful() {
    return Sequence.fromIterable(MapSequence.fromMap(results).values()).all((r) -> r.isSucessful());
  }
  @Override
  public Iterable<IResource> output() {
    if (MapSequence.fromMap(results).isEmpty()) {
      return null;
    }
    return Sequence.fromIterable(MapSequence.fromMap(results).values()).last().output();
  }
}
