package constraints.rules.test.constraints;

/*Generated by MPS */

import jetbrains.mps.core.aspects.constraints.rules.BaseRulesConstraintsDescriptor;
import org.jetbrains.mps.openapi.language.SAbstractConcept;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import jetbrains.mps.core.aspects.constraints.rules.Rule;
import jetbrains.mps.core.aspects.constraints.rules.kinds.CanBeRootContext;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;
import org.jetbrains.annotations.NotNull;
import jetbrains.mps.core.aspects.constraints.rules.BaseRule;
import org.jetbrains.mps.openapi.model.SNodeReference;
import org.jetbrains.mps.openapi.persistence.PersistenceFacade;
import jetbrains.mps.core.aspects.constraints.rules.RuleId;
import jetbrains.mps.core.aspects.constraints.rules.kinds.PredefinedRuleKinds;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SModelOperations;

public final class SometimesRootableConcept_ConstraintRules extends BaseRulesConstraintsDescriptor {
  private static final SAbstractConcept CONCEPT = MetaAdapterFactory.getConcept(0xfc39d7264089464aL, 0x8fc15f71edfdf03bL, 0x456133ee8100e75cL, "constraints.rules.test.structure.SometimesRootableConcept");

  public static final Rule<CanBeRootContext> check_id4999334160817514363 = new Rule_unnamed_10yvtm_a0();

  private static final List<Rule<?>> RULES = Collections.unmodifiableList(Arrays.<Rule<?>>asList(check_id4999334160817514363));

  @NotNull
  @Override
  public List<Rule<?>> getDeclaredRules() {
    return RULES;
  }

  public static final class Rule_unnamed_10yvtm_a0 extends BaseRule<CanBeRootContext> {
    private static final SNodeReference SOURCE_NODE_REF = PersistenceFacade.getInstance().createNodeReference("r:50e6e59b-26e4-4ba1-9996-7aefbabd31cf(constraints.rules.test.constraints)/4999334160817514363");
    public static final RuleId ID_unnamed_10yvtm_a0 = new RuleId(4999334160817514363L, SOURCE_NODE_REF);

    public Rule_unnamed_10yvtm_a0() {
      super(CONCEPT, PredefinedRuleKinds.CAN_BE_ROOT, ID_unnamed_10yvtm_a0, SOURCE_NODE_REF);
    }

    @Override
    public boolean check(@NotNull CanBeRootContext context) {
      return SModelOperations.getModelName(context.getModel()).startsWith("A");
    }

    @Override
    public boolean appliesTo(@NotNull CanBeRootContext context) {
      return true;
    }

  }

  /*package*/ SometimesRootableConcept_ConstraintRules() {
    super(CONCEPT);
  }
}
