package jetbrains.mps.lang.migration.behavior;
/*Generated by MPS */
import jetbrains.mps.core.aspects.behaviour.BaseBHDescriptor;
import org.jetbrains.mps.openapi.language.SAbstractConcept;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import jetbrains.mps.core.aspects.behaviour.api.BehaviorRegistry;
import jetbrains.mps.smodel.language.ConceptRegistry;
import jetbrains.mps.core.aspects.behaviour.api.SMethod;
import org.jetbrains.mps.openapi.model.SNodeReference;
import jetbrains.mps.core.aspects.behaviour.SMethodBuilder;
import jetbrains.mps.core.aspects.behaviour.SJavaCompoundTypeImpl;
import jetbrains.mps.core.aspects.behaviour.SModifiersImpl;
import jetbrains.mps.core.aspects.behaviour.AccessPrivileges;
import org.jetbrains.mps.openapi.model.SNode;
import org.jetbrains.mps.openapi.module.SRepository;
import org.jetbrains.mps.openapi.model.SReference;
import java.util.List;
import java.util.Arrays;
import org.jetbrains.annotations.NotNull;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations;
import jetbrains.mps.smodel.SNodePointer;
import jetbrains.mps.core.aspects.behaviour.api.SConstructor;
import org.jetbrains.annotations.Nullable;
import jetbrains.mps.core.aspects.behaviour.api.BHMethodNotFoundException;
public final class ReflectionNodeReference__BehaviorDescriptor extends BaseBHDescriptor {
private static final SAbstractConcept CONCEPT = MetaAdapterFactory.getConcept(0x9074634404fd4286L, 0x97d5b46ae6a81709L, 0x27bf3263be23f0dfL, "jetbrains.mps.lang.migration.structure.ReflectionNodeReference");
private static final BehaviorRegistry REGISTRY = ConceptRegistry.getInstance().getBehaviorRegistry();
public static final SMethod<SNodeReference> getNodeReference_id4uVwhQyQbdz = new SMethodBuilder<SNodeReference>(new SJavaCompoundTypeImpl(SNodeReference.class)).name("getNodeReference").modifiers(SModifiersImpl.create(8, AccessPrivileges.PUBLIC)).concept(CONCEPT).id("4uVwhQyQbdz").registry(REGISTRY).build();
public static final SMethod<SNode> tryToFindNode_id6szrkDoc2K7 = new SMethodBuilder<SNode>(new SJavaCompoundTypeImpl((Class<SNode>) ((Class) Object.class))).name("tryToFindNode").modifiers(SModifiersImpl.create(8, AccessPrivileges.PUBLIC)).concept(CONCEPT).id("6szrkDoc2K7").registry(REGISTRY).build(SMethodBuilder.createJavaParameter(SRepository.class, ""));
public static final SMethod<Boolean> isSameTarget_id6szrkDoc2JJ = new SMethodBuilder<Boolean>(new SJavaCompoundTypeImpl(Boolean.TYPE)).name("isSameTarget").modifiers(SModifiersImpl.create(8, AccessPrivileges.PUBLIC)).concept(CONCEPT).id("6szrkDoc2JJ").registry(REGISTRY).build(SMethodBuilder.createJavaParameter(SReference.class, ""));
public static final SMethod<String> getPresentation_idhEwIMiw = new SMethodBuilder<String>(new SJavaCompoundTypeImpl(String.class)).name("getPresentation").modifiers(SModifiersImpl.create(8, AccessPrivileges.PUBLIC)).concept(CONCEPT).id("hEwIMiw").registry(REGISTRY).build();
private static final List<SMethod<?>> BH_METHODS = Arrays.<SMethod<?>>asList(getNodeReference_id4uVwhQyQbdz, tryToFindNode_id6szrkDoc2K7, isSameTarget_id6szrkDoc2JJ, getPresentation_idhEwIMiw);
private static void ___init___(@NotNull SNode __thisNode__) {
}
/*package*/ static SNodeReference getNodeReference_id4uVwhQyQbdz(@NotNull SNode __thisNode__) {
if (isEmptyString(SPropertyOperations.getString(__thisNode__, MetaAdapterFactory.getProperty(0x9074634404fd4286L, 0x97d5b46ae6a81709L, 0x27bf3263be23f0dfL, 0x27bf3263be23f443L, "modelRef"))) || isEmptyString(SPropertyOperations.getString(__thisNode__, MetaAdapterFactory.getProperty(0x9074634404fd4286L, 0x97d5b46ae6a81709L, 0x27bf3263be23f0dfL, 0x27bf3263be23f44fL, "nodeId")))) {
return null;
}
SNodePointer result = null;
try {
result = new SNodePointer(SPropertyOperations.getString(__thisNode__, MetaAdapterFactory.getProperty(0x9074634404fd4286L, 0x97d5b46ae6a81709L, 0x27bf3263be23f0dfL, 0x27bf3263be23f443L, "modelRef")), SPropertyOperations.getString(__thisNode__, MetaAdapterFactory.getProperty(0x9074634404fd4286L, 0x97d5b46ae6a81709L, 0x27bf3263be23f0dfL, 0x27bf3263be23f44fL, "nodeId")));
} catch (IllegalArgumentException ignored) {
}
return result;
}
/*package*/ static SNode tryToFindNode_id6szrkDoc2K7(@NotNull SNode __thisNode__, SRepository repository) {
return check_gp0spl_a0a1(AbstractNodeReference__BehaviorDescriptor.getNodeReference_id4uVwhQyQbdz.invoke(__thisNode__), repository);
}
/*package*/ static boolean isSameTarget_id6szrkDoc2JJ(@NotNull SNode __thisNode__, SReference reference) {
SNodeReference myReference = AbstractNodeReference__BehaviorDescriptor.getNodeReference_id4uVwhQyQbdz.invoke(__thisNode__);
return myReference != null && myReference.equals(reference.getTargetNodeReference());
}
/*package*/ static String getPresentation_idhEwIMiw(@NotNull SNode __thisNode__) {
return SPropertyOperations.getString(__thisNode__, MetaAdapterFactory.getProperty(0x9074634404fd4286L, 0x97d5b46ae6a81709L, 0x27bf3263be23f0dfL, 0x27bf3263be23f299L, "nodeName"));
}
/*package*/ ReflectionNodeReference__BehaviorDescriptor() {
super(REGISTRY);
}
@Override
protected void initNode(@NotNull SNode node, @NotNull SConstructor constructor, @Nullable Object[] parameters) {
___init___(node);
}
@Override
protected <T> T invokeSpecial0(@NotNull SNode node, @NotNull SMethod<T> method, @Nullable Object[] parameters) {
int methodIndex = BH_METHODS.indexOf(method);
if (methodIndex < 0) {
throw new BHMethodNotFoundException(this, method);
}
switch (methodIndex) {
case 0:
return (T) ((SNodeReference) getNodeReference_id4uVwhQyQbdz(node));
case 1:
return (T) ((SNode) tryToFindNode_id6szrkDoc2K7(node, (SRepository) parameters[0]));
case 2:
return (T) ((Boolean) isSameTarget_id6szrkDoc2JJ(node, (SReference) parameters[0]));
case 3:
return (T) ((String) getPresentation_idhEwIMiw(node));
default:
throw new BHMethodNotFoundException(this, method);
}
}
@Override
protected <T> T invokeSpecial0(@NotNull SAbstractConcept concept, @NotNull SMethod<T> method, @Nullable Object[] parameters) {
int methodIndex = BH_METHODS.indexOf(method);
if (methodIndex < 0) {
throw new BHMethodNotFoundException(this, method);
}
switch (methodIndex) {
default:
throw new BHMethodNotFoundException(this, method);
}
}
@NotNull
@Override
public List<SMethod<?>> getDeclaredMethods() {
return BH_METHODS;
}
@NotNull
@Override
public SAbstractConcept getConcept() {
return CONCEPT;
}
private static boolean isEmptyString(String str) {
return str == null || str.length() == 0;
}
private static SNode check_gp0spl_a0a1(SNodeReference checkedDotOperand, SRepository repository) {
if (null != checkedDotOperand) {
return checkedDotOperand.resolve(repository);
}
return null;
}
}