package jetbrains.mps.lang.smodel.generator.smodelAdapter;
/*Generated by MPS */
import org.jetbrains.annotations.NotNull;
import org.jetbrains.mps.openapi.model.SNode;
import org.jetbrains.mps.openapi.language.SAbstractConcept;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.mps.openapi.language.SConcept;
import org.jetbrains.mps.openapi.language.SReferenceLink;
import org.jetbrains.mps.openapi.language.SContainmentLink;
import org.jetbrains.mps.openapi.language.SProperty;
public interface IAttributeDescriptor {
boolean match(@NotNull SNode attribute);
void update(@NotNull SNode attribute);
class AttributeDescriptor implements IAttributeDescriptor {
protected SAbstractConcept myAttributeConcept;
public AttributeDescriptor(@Nullable SAbstractConcept attributeConceptName) {
myAttributeConcept = attributeConceptName;
}
@Override
public boolean match(@NotNull SNode attribute) {
return myAttributeConcept == null || SNodeOperations.isInstanceOf(attribute, myAttributeConcept);
}
@Override
public void update(@NotNull SNode attribute) {
}
}
class AllAttributes extends IAttributeDescriptor.AttributeDescriptor {
public AllAttributes() {
super((SAbstractConcept) null);
}
}
class NodeAttribute extends IAttributeDescriptor.AttributeDescriptor {
public NodeAttribute(@NotNull SConcept attributeDeclaration) {
super(attributeDeclaration);
}
}
class LinkAttribute extends IAttributeDescriptor.AttributeDescriptor {
private SReferenceLink myLink;
public LinkAttribute(@NotNull SConcept attributeDeclaration, SReferenceLink link) {
super(attributeDeclaration);
myLink = link;
}
@Override
public boolean match(@NotNull SNode attribute) {
return super.match(attribute) && (myLink == null || myLink.equals(AttributeOperations.getLink(attribute)));
}
@Override
public void update(@NotNull SNode attribute) {
AttributeOperations.setLink(attribute, myLink);
}
}
class ChildAttribute extends IAttributeDescriptor.AttributeDescriptor {
private SContainmentLink myLink;
public ChildAttribute(@NotNull SConcept attributeDeclaration, SContainmentLink link) {
super(attributeDeclaration);
myLink = link;
}
@Override
public boolean match(@NotNull SNode attribute) {
return super.match(attribute) && (myLink == null || myLink.equals(AttributeOperations.getChildLink(attribute)));
}
@Override
public void update(@NotNull SNode attribute) {
AttributeOperations.setLink(attribute, myLink);
}
}
class PropertyAttribute extends IAttributeDescriptor.AttributeDescriptor {
private SProperty myProperty;
public PropertyAttribute(@NotNull SConcept attributeDeclaration, @NotNull SProperty property) {
super(attributeDeclaration);
myProperty = property;
}
@Override
public boolean match(@NotNull SNode attribute) {
return super.match(attribute) && (myProperty == null || myProperty.equals(AttributeOperations.getProperty(attribute)));
}
@Override
public void update(@NotNull SNode attribute) {
AttributeOperations.setProperty(attribute, myProperty);
}
}
}