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

import com.google.inject.Inject;
import com.irtsaintexupery.pseim.mapping.CardinalityValue;
import com.irtsaintexupery.pseim.mapping.GraphElementMapping;
import com.irtsaintexupery.pseim.mapping.MappingPackage;
import com.irtsaintexupery.pseim.mapping.PatternApplication;
import com.irtsaintexupery.pseim.mapping.PortMapping;
import com.irtsaintexupery.xtext.pseim.services.MappingGrammarAccess;
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 MappingSemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private MappingGrammarAccess 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 == MappingPackage.eINSTANCE)
			switch (semanticObject.eClass().getClassifierID()) {
			case MappingPackage.CARDINALITY_VALUE:
				sequence_CardinalityValue(context, (CardinalityValue) semanticObject); 
				return; 
			case MappingPackage.GRAPH_ELEMENT_MAPPING:
				sequence_GraphElementMapping(context, (GraphElementMapping) semanticObject); 
				return; 
			case MappingPackage.PATTERN_APPLICATION:
				sequence_PatternApplication(context, (PatternApplication) semanticObject); 
				return; 
			case MappingPackage.PORT_MAPPING:
				sequence_PortMapping(context, (PortMapping) semanticObject); 
				return; 
			}
		if (errorAcceptor != null)
			errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Contexts:
	 *     CardinalityValue returns CardinalityValue
	 *
	 * Constraint:
	 *     (cardinalityElement=[CardinalityElement|QualifiedID] value=EInt)
	 */
	protected void sequence_CardinalityValue(ISerializationContext context, CardinalityValue semanticObject) {
		if (errorAcceptor != null) {
			if (transientValues.isValueTransient(semanticObject, MappingPackage.Literals.CARDINALITY_VALUE__CARDINALITY_ELEMENT) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MappingPackage.Literals.CARDINALITY_VALUE__CARDINALITY_ELEMENT));
			if (transientValues.isValueTransient(semanticObject, MappingPackage.Literals.CARDINALITY_VALUE__VALUE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, MappingPackage.Literals.CARDINALITY_VALUE__VALUE));
		}
		SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
		feeder.accept(grammarAccess.getCardinalityValueAccess().getCardinalityElementCardinalityElementQualifiedIDParserRuleCall_0_0_1(), semanticObject.eGet(MappingPackage.Literals.CARDINALITY_VALUE__CARDINALITY_ELEMENT, false));
		feeder.accept(grammarAccess.getCardinalityValueAccess().getValueEIntParserRuleCall_2_0(), semanticObject.getValue());
		feeder.finish();
	}
	
	
	/**
	 * Contexts:
	 *     GraphElementMapping returns GraphElementMapping
	 *
	 * Constraint:
	 *     (modelGraphElement+=[GraphElement|QualifiedID] modelGraphElement+=[GraphElement|QualifiedID]* patternGraphElement=[GraphElement|QualifiedID])
	 */
	protected void sequence_GraphElementMapping(ISerializationContext context, GraphElementMapping semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Contexts:
	 *     PatternApplication returns PatternApplication
	 *
	 * Constraint:
	 *     (
	 *         model=[Model|ID] 
	 *         pattern=[Pattern|ID] 
	 *         (cardinalityValues+=CardinalityValue cardinalityValues+=CardinalityValue*)? 
	 *         (modelElement+=GraphElementMapping modelElement+=GraphElementMapping*)? 
	 *         (portMapping+=PortMapping portMapping+=PortMapping*)?
	 *     )
	 */
	protected void sequence_PatternApplication(ISerializationContext context, PatternApplication semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Contexts:
	 *     PortMapping returns PortMapping
	 *
	 * Constraint:
	 *     (modelPort+=[BorderElement|QualifiedID] modelPort+=[BorderElement|QualifiedID]* patternPort=[BorderElement|QualifiedID])
	 */
	protected void sequence_PortMapping(ISerializationContext context, PortMapping semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
}
