/*
 * generated by Xtext 2.12.0
 */
package com.irtsaintexupery.xtext.pseim.serializer;

import com.google.inject.Inject;
import com.irtsaintexupery.pseim.pseim.CardinalityElement;
import com.irtsaintexupery.pseim.pseim.Pattern;
import com.irtsaintexupery.pseim.pseim.PatternComponent;
import com.irtsaintexupery.pseim.pseim.PatternLink;
import com.irtsaintexupery.pseim.pseim.PatternPort;
import com.irtsaintexupery.pseim.pseim.PseimPackage;
import com.irtsaintexupery.pseim.seim.SeimPackage;
import com.irtsaintexupery.xtext.pseim.services.PatternGrammarAccess;
import java.util.Set;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.xtext.Action;
import org.eclipse.xtext.Parameter;
import org.eclipse.xtext.ParserRule;
import org.eclipse.xtext.serializer.ISerializationContext;
import org.eclipse.xtext.serializer.acceptor.SequenceFeeder;
import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient;

@SuppressWarnings("all")
public class PatternSemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private PatternGrammarAccess grammarAccess;
	
	@Override
	public void sequence(ISerializationContext context, EObject semanticObject) {
		EPackage epackage = semanticObject.eClass().getEPackage();
		ParserRule rule = context.getParserRule();
		Action action = context.getAssignedAction();
		Set<Parameter> parameters = context.getEnabledBooleanParameters();
		if (epackage == PseimPackage.eINSTANCE)
			switch (semanticObject.eClass().getClassifierID()) {
			case PseimPackage.CARDINALITY_ELEMENT:
				sequence_CardinalityElement(context, (CardinalityElement) semanticObject); 
				return; 
			case PseimPackage.PATTERN:
				sequence_Pattern(context, (Pattern) semanticObject); 
				return; 
			case PseimPackage.PATTERN_COMPONENT:
				sequence_PatternComponent(context, (PatternComponent) semanticObject); 
				return; 
			case PseimPackage.PATTERN_LINK:
				sequence_PatternLink(context, (PatternLink) semanticObject); 
				return; 
			case PseimPackage.PATTERN_PORT:
				sequence_PatternPort(context, (PatternPort) semanticObject); 
				return; 
			}
		if (errorAcceptor != null)
			errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Contexts:
	 *     CardinalityElement returns CardinalityElement
	 *
	 * Constraint:
	 *     name=ID
	 */
	protected void sequence_CardinalityElement(ISerializationContext context, CardinalityElement semanticObject) {
		if (errorAcceptor != null) {
			if (transientValues.isValueTransient(semanticObject, SeimPackage.Literals.NAMED_ELEMENT__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, SeimPackage.Literals.NAMED_ELEMENT__NAME));
		}
		SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
		feeder.accept(grammarAccess.getCardinalityElementAccess().getNameIDTerminalRuleCall_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Contexts:
	 *     PatternComponent returns PatternComponent
	 *
	 * Constraint:
	 *     (
	 *         name=ID 
	 *         (multiplicityValue=INT | cardinalityElement=[CardinalityElement|ID])? 
	 *         (content+=PatternPort content+=PatternPort*)? 
	 *         content+=PatternComponent? 
	 *         (content+=PatternLink? content+=PatternComponent?)*
	 *     )
	 */
	protected void sequence_PatternComponent(ISerializationContext context, PatternComponent semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Contexts:
	 *     PatternLink returns PatternLink
	 *
	 * Constraint:
	 *     (src=[PatternPort|QualifiedID] linkType=LinkType dst=[PatternPort|QualifiedID])
	 */
	protected void sequence_PatternLink(ISerializationContext context, PatternLink semanticObject) {
		if (errorAcceptor != null) {
			if (transientValues.isValueTransient(semanticObject, SeimPackage.Literals.LINK__SRC) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, SeimPackage.Literals.LINK__SRC));
			if (transientValues.isValueTransient(semanticObject, PseimPackage.Literals.PATTERN_LINK__LINK_TYPE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PseimPackage.Literals.PATTERN_LINK__LINK_TYPE));
			if (transientValues.isValueTransient(semanticObject, SeimPackage.Literals.LINK__DST) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, SeimPackage.Literals.LINK__DST));
		}
		SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
		feeder.accept(grammarAccess.getPatternLinkAccess().getSrcPatternPortQualifiedIDParserRuleCall_0_0_1(), semanticObject.eGet(SeimPackage.Literals.LINK__SRC, false));
		feeder.accept(grammarAccess.getPatternLinkAccess().getLinkTypeLinkTypeEnumRuleCall_2_0(), semanticObject.getLinkType());
		feeder.accept(grammarAccess.getPatternLinkAccess().getDstPatternPortQualifiedIDParserRuleCall_4_0_1(), semanticObject.eGet(SeimPackage.Literals.LINK__DST, false));
		feeder.finish();
	}
	
	
	/**
	 * Contexts:
	 *     PatternPort returns PatternPort
	 *
	 * Constraint:
	 *     (dir=PatternPortDirection name=ID (multiplicityValue=INT | cardinalityElement=[CardinalityElement|ID])?)
	 */
	protected void sequence_PatternPort(ISerializationContext context, PatternPort semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Contexts:
	 *     Pattern returns Pattern
	 *
	 * Constraint:
	 *     (
	 *         name=ID 
	 *         (cardinalityElements+=CardinalityElement cardinalityElements+=CardinalityElement*)? 
	 *         (modelElements+=PatternComponent | modelElements+=PatternLink)*
	 *     )
	 */
	protected void sequence_Pattern(ISerializationContext context, Pattern semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
}
