package jetbrains.mps.lang.constraints.rules.kinds.constraints;

/*Generated by MPS */

import jetbrains.mps.smodel.runtime.base.BaseConstraintsDescriptor;
import jetbrains.mps.smodel.runtime.ConstraintFunction;
import jetbrains.mps.smodel.runtime.ConstraintContext_CanBeRoot;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import jetbrains.mps.smodel.runtime.CheckingNodeContext;
import org.jetbrains.mps.openapi.model.SModel;
import java.util.Objects;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SModelOperations;
import org.jetbrains.mps.openapi.persistence.PersistenceFacade;
import jetbrains.mps.smodel.SNodePointer;
import org.jetbrains.mps.openapi.language.SConcept;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;

public class RuleKind_Constraints extends BaseConstraintsDescriptor {
  public RuleKind_Constraints() {
    super(CONCEPTS.RuleKind$7C);
  }

  @Override
  public ConstraintFunction<ConstraintContext_CanBeRoot, Boolean> calculateCanBeRootConstraint() {
    return new ConstraintFunction<ConstraintContext_CanBeRoot, Boolean>() {
      @NotNull
      public Boolean invoke(@NotNull ConstraintContext_CanBeRoot context, @Nullable CheckingNodeContext checkingNodeContext) {
        boolean result = staticCanBeARoot(context.getModel());

        if (!(result) && checkingNodeContext != null) {
          checkingNodeContext.setBreakingNode(canBeRootBreakingPoint);
        }

        return result;
      }
    };
  }
  private static boolean staticCanBeARoot(SModel model) {
    return Objects.equals(SModelOperations.getPointer(model), PersistenceFacade.getInstance().createModelReference("r:52ea8481-08b2-4cbd-ad9d-1b42825f7d09(jetbrains.mps.lang.constraints.rules.kinds.constraints)"));
  }
  private static final SNodePointer canBeRootBreakingPoint = new SNodePointer("r:52ea8481-08b2-4cbd-ad9d-1b42825f7d09(jetbrains.mps.lang.constraints.rules.kinds.constraints)", "4575984242822668306");

  private static final class CONCEPTS {
    /*package*/ static final SConcept RuleKind$7C = MetaAdapterFactory.getConcept(0x5dae8159ab9946bbL, 0xa40d0cee30ee7018L, 0x6530303593554248L, "jetbrains.mps.lang.constraints.rules.kinds.structure.RuleKind");
  }
}
