package jetbrains.mps.transformation.test.errorReporting.generator.template.main;
/*Generated by MPS */
import jetbrains.mps.generator.runtime.Generated;
import jetbrains.mps.generator.impl.query.QueryProviderBase;
import jetbrains.mps.generator.template.BaseMappingRuleContext;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.generator.template.WeavingMappingRuleContext;
import java.util.Map;
import java.util.HashMap;
import org.jetbrains.annotations.NotNull;
import jetbrains.mps.generator.impl.query.WeaveRuleCondition;
import jetbrains.mps.generator.impl.query.QueryKey;
import jetbrains.mps.generator.impl.query.WeaveRuleQuery;
import jetbrains.mps.generator.impl.query.WeaveAnchorQuery;
import jetbrains.mps.generator.impl.GenerationFailureException;
import org.jetbrains.annotations.Nullable;
import jetbrains.mps.generator.template.WeavingAnchorContext;
@Generated
public class QueriesGenerated extends QueryProviderBase {
public QueriesGenerated() {
super(1);
}
public static boolean baseMappingRule_Condition_7287346816896135373(final BaseMappingRuleContext _context) {
return SPropertyOperations.getInteger(_context.getNode(), MetaAdapterFactory.getProperty(0x99a58581851840c8L, 0x81f1e364306f5ffcL, 0x6521db51e82a7653L, 0x6521db51e82a9208L, "intval")) == 42;
}
public static SNode weaving_MappingRule_ContextNodeQuery_7287346816896128676(final WeavingMappingRuleContext _context) {
return null;
}
public static SNode weaving_MappingRule_ContextNodeQuery_6145560071556216092(final WeavingMappingRuleContext _context) {
return _context.getOutputNodeByMappingLabel("aaa", null);
}
private final Map<String, QueriesGenerated.WRQ> wrcnMethods = new HashMap<String, QueriesGenerated.WRQ>();
{
int i = 0;
wrcnMethods.put("7287346816896128674", new QueriesGenerated.WRQ(i++));
wrcnMethods.put("6145560071556216090", new QueriesGenerated.WRQ(i++));
}
@Override
@NotNull
public WeaveRuleCondition getWeaveRuleCondition(@NotNull QueryKey identity) {
final String id = identity.getTemplateNode().getNodeId().toString();
if (!(wrcnMethods.containsKey(id))) {
return super.getWeaveRuleCondition(identity);
}
return wrcnMethods.get(id);
}
@Override
@NotNull
public WeaveRuleQuery getWeaveRuleQuery(@NotNull QueryKey identity) {
final String id = identity.getTemplateNode().getNodeId().toString();
if (!(wrcnMethods.containsKey(id))) {
return super.getWeaveRuleQuery(identity);
}
return wrcnMethods.get(id);
}
@NotNull
@Override
public WeaveAnchorQuery getWeaveAnchorQuery(@NotNull QueryKey identity) {
final String id = identity.getTemplateNode().getNodeId().toString();
if (!(wrcnMethods.containsKey(id))) {
return super.getWeaveAnchorQuery(identity);
}
return wrcnMethods.get(id);
}
private static class WRQ implements WeaveRuleQuery, WeaveRuleCondition, WeaveAnchorQuery {
private final int methodKey;
public WRQ(int methodKey) {
this.methodKey = methodKey;
}
@Override
public boolean check(@NotNull WeavingMappingRuleContext ctx) throws GenerationFailureException {
switch (methodKey) {
case 0:
return QueriesGenerated.baseMappingRule_Condition_7287346816896135373(ctx);
case 1:
return true;
default:
throw new GenerationFailureException(String.format("Inconsistent QueriesGenerated: there's no condition method for rule %s (key: #%d)", ctx.getTemplateReference(), methodKey));
}
}
@Override
public SNode contextNode(WeavingMappingRuleContext ctx) throws GenerationFailureException {
switch (methodKey) {
case 0:
return QueriesGenerated.weaving_MappingRule_ContextNodeQuery_7287346816896128676(ctx);
case 1:
return QueriesGenerated.weaving_MappingRule_ContextNodeQuery_6145560071556216092(ctx);
default:
throw new GenerationFailureException(String.format("Inconsistent QueriesGenerated: there's no context node query method for weaving rule %s (key: #%d)", ctx.getTemplateReference(), methodKey));
}
}
@Nullable
@Override
public SNode anchorNode(WeavingAnchorContext ctx) throws GenerationFailureException {
switch (methodKey) {
case 0:
return null;
case 1:
return null;
default:
throw new GenerationFailureException(String.format("Inconsistent QueriesGenerated: there's no anchor query method for rule %s (key: #%d)", ctx.getTemplateReference(), methodKey));
}
}
}
}