package jetbrains.mps.tool.environment; /*Generated by MPS */ import org.jetbrains.annotations.NotNull; import jetbrains.mps.project.Project; import org.jetbrains.annotations.Nullable; public class CompositeProjectStrategy implements ProjectStrategy { private final ProjectStrategy[] myStrategies; public CompositeProjectStrategy(ProjectStrategy... strategies) { myStrategies = strategies; } @NotNull @Override public Project create(@NotNull Environment env) { ProjectStrategy firstApplicable = getFirstApplicable(); if (firstApplicable != null) { return firstApplicable.create(env); } throw new IllegalStateException("Could not create project with given strategies, nothing is applicable"); } @Override public boolean isApplicable() { return getFirstApplicable() != null; } @Nullable private ProjectStrategy getFirstApplicable() { for (ProjectStrategy strategy : myStrategies) { if (strategy.isApplicable()) { return strategy; } } return null; } }