package org.xtext.example.domij.serializer;

import com.google.inject.Inject;
import com.google.inject.Provider;
import er.Attribute;
import er.AttributeDomain;
import er.Categories;
import er.Categorisation;
import er.Domain;
import er.ERModel;
import er.Entity;
import er.ErPackage;
import er.Gerund;
import er.ISA;
import er.IdentificationDependency;
import er.Key;
import er.RegularEntity;
import er.Relationship;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor;
import org.eclipse.xtext.serializer.acceptor.SequenceFeeder;
import org.eclipse.xtext.serializer.diagnostic.ISemanticSequencerDiagnosticProvider;
import org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor;
import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.GenericSequencer;
import org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient;
import org.xtext.example.domij.services.ErDslGrammarAccess;

@SuppressWarnings("all")
public abstract class AbstractErDslSemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private ErDslGrammarAccess grammarAccess;
	
	public void createSequence(EObject context, EObject semanticObject) {
		if(semanticObject.eClass().getEPackage() == ErPackage.eINSTANCE) switch(semanticObject.eClass().getClassifierID()) {
			case ErPackage.ATTRIBUTE:
				if(context == grammarAccess.getAttributeRule()) {
					sequence_Attribute(context, (Attribute) semanticObject); 
					return; 
				}
				else break;
			case ErPackage.ATTRIBUTE_DOMAIN:
				if(context == grammarAccess.getAttributeDomainRule()) {
					sequence_AttributeDomain(context, (AttributeDomain) semanticObject); 
					return; 
				}
				else break;
			case ErPackage.CATEGORIES:
				if(context == grammarAccess.getCategoriesRule()) {
					sequence_Categories(context, (Categories) semanticObject); 
					return; 
				}
				else break;
			case ErPackage.CATEGORISATION:
				if(context == grammarAccess.getCategorisationRule() ||
				   context == grammarAccess.getRelationshipConceptRule()) {
					sequence_Categorisation(context, (Categorisation) semanticObject); 
					return; 
				}
				else break;
			case ErPackage.DOMAIN:
				if(context == grammarAccess.getDomainRule()) {
					sequence_Domain(context, (Domain) semanticObject); 
					return; 
				}
				else break;
			case ErPackage.ER_MODEL:
				if(context == grammarAccess.getERModelRule()) {
					sequence_ERModel(context, (ERModel) semanticObject); 
					return; 
				}
				else break;
			case ErPackage.ENTITY:
				if(context == grammarAccess.getEntityRule() ||
				   context == grammarAccess.getEntityConceptRule()) {
					sequence_Entity(context, (Entity) semanticObject); 
					return; 
				}
				else break;
			case ErPackage.GERUND:
				if(context == grammarAccess.getEntityConceptRule() ||
				   context == grammarAccess.getGerundRule()) {
					sequence_Gerund(context, (Gerund) semanticObject); 
					return; 
				}
				else break;
			case ErPackage.ISA:
				if(context == grammarAccess.getISARule() ||
				   context == grammarAccess.getRelationshipConceptRule()) {
					sequence_ISA(context, (ISA) semanticObject); 
					return; 
				}
				else break;
			case ErPackage.IDENTIFICATION_DEPENDENCY:
				if(context == grammarAccess.getIdentificationDependencyRule() ||
				   context == grammarAccess.getRelationshipConceptRule()) {
					sequence_IdentificationDependency(context, (IdentificationDependency) semanticObject); 
					return; 
				}
				else break;
			case ErPackage.KEY:
				if(context == grammarAccess.getKeyRule()) {
					sequence_Key(context, (Key) semanticObject); 
					return; 
				}
				else break;
			case ErPackage.REGULAR_ENTITY:
				if(context == grammarAccess.getRegularEntityRule()) {
					sequence_RegularEntity(context, (RegularEntity) semanticObject); 
					return; 
				}
				else break;
			case ErPackage.RELATIONSHIP:
				if(context == grammarAccess.getRelationshipRule() ||
				   context == grammarAccess.getRelationshipConceptRule()) {
					sequence_Relationship(context, (Relationship) semanticObject); 
					return; 
				}
				else break;
			}
		if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Constraint:
	 *     (domain=[Domain|EString] length=EInt? default=EString?)
	 */
	protected void sequence_AttributeDomain(EObject context, AttributeDomain semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=EString attributeDomain=AttributeDomain?)
	 */
	protected void sequence_Attribute(EObject context, Attribute semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (entities+=[EntityConcept|EString] entities+=[EntityConcept|EString]* min=MinCardinality max=MaxCardinality)
	 */
	protected void sequence_Categories(EObject context, Categories semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=EString categorisedEntity=[EntityConcept|EString] categorisationEntities=Categories isPartial?=EBoolean)
	 */
	protected void sequence_Categorisation(EObject context, Categorisation semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, ErPackage.Literals.MODELLING_CONCEPT__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ErPackage.Literals.MODELLING_CONCEPT__NAME));
			if(transientValues.isValueTransient(semanticObject, ErPackage.Literals.CATEGORISATION__CATEGORISATION_ENTITIES) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ErPackage.Literals.CATEGORISATION__CATEGORISATION_ENTITIES));
			if(transientValues.isValueTransient(semanticObject, ErPackage.Literals.CATEGORISATION__IS_PARTIAL) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ErPackage.Literals.CATEGORISATION__IS_PARTIAL));
			if(transientValues.isValueTransient(semanticObject, ErPackage.Literals.CATEGORISATION__CATEGORISED_ENTITY) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ErPackage.Literals.CATEGORISATION__CATEGORISED_ENTITY));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getCategorisationAccess().getNameEStringParserRuleCall_1_0(), semanticObject.getName());
		feeder.accept(grammarAccess.getCategorisationAccess().getCategorisedEntityEntityConceptEStringParserRuleCall_4_0_1(), semanticObject.getCategorisedEntity());
		feeder.accept(grammarAccess.getCategorisationAccess().getCategorisationEntitiesCategoriesParserRuleCall_6_0(), semanticObject.getCategorisationEntities());
		feeder.accept(grammarAccess.getCategorisationAccess().getIsPartialEBooleanParserRuleCall_8_0(), semanticObject.isIsPartial());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=EString primitiveDomain=PrimitiveDomain)
	 */
	protected void sequence_Domain(EObject context, Domain semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, ErPackage.Literals.MODELLING_CONCEPT__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ErPackage.Literals.MODELLING_CONCEPT__NAME));
			if(transientValues.isValueTransient(semanticObject, ErPackage.Literals.DOMAIN__PRIMITIVE_DOMAIN) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ErPackage.Literals.DOMAIN__PRIMITIVE_DOMAIN));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getDomainAccess().getNameEStringParserRuleCall_1_0(), semanticObject.getName());
		feeder.accept(grammarAccess.getDomainAccess().getPrimitiveDomainPrimitiveDomainParserRuleCall_3_0(), semanticObject.getPrimitiveDomain());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (
	 *         name=EString 
	 *         (domains+=Domain domains+=Domain*)? 
	 *         (entities+=Entity entities+=Entity*)? 
	 *         (gerunds+=Gerund gerunds+=Gerund*)? 
	 *         (relationships+=RelationshipConcept relationships+=RelationshipConcept*)?
	 *     )
	 */
	protected void sequence_ERModel(EObject context, ERModel semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=EString (entityAttributes+=Attribute entityAttributes+=Attribute*)? (keySet+=Key keySet+=Key*)? primaryKey=[Key|EString]?)
	 */
	protected void sequence_Entity(EObject context, Entity semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     relationship=Relationship
	 */
	protected void sequence_Gerund(EObject context, Gerund semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, ErPackage.Literals.GERUND__RELATIONSHIP) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ErPackage.Literals.GERUND__RELATIONSHIP));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getGerundAccess().getRelationshipRelationshipParserRuleCall_0(), semanticObject.getRelationship());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=EString supertype=RegularEntity subtypes+=[Entity|EString] subtypes+=[Entity|EString]* classificationAttribute=[Attribute|EString])
	 */
	protected void sequence_ISA(EObject context, ISA semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=EString weakEntity=[Entity|EString] regularEntity=RegularEntity)
	 */
	protected void sequence_IdentificationDependency(EObject context, IdentificationDependency semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, ErPackage.Literals.MODELLING_CONCEPT__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ErPackage.Literals.MODELLING_CONCEPT__NAME));
			if(transientValues.isValueTransient(semanticObject, ErPackage.Literals.IDENTIFICATION_DEPENDENCY__WEAK_ENTITY) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ErPackage.Literals.IDENTIFICATION_DEPENDENCY__WEAK_ENTITY));
			if(transientValues.isValueTransient(semanticObject, ErPackage.Literals.IDENTIFICATION_DEPENDENCY__REGULAR_ENTITY) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ErPackage.Literals.IDENTIFICATION_DEPENDENCY__REGULAR_ENTITY));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getIdentificationDependencyAccess().getNameEStringParserRuleCall_1_0(), semanticObject.getName());
		feeder.accept(grammarAccess.getIdentificationDependencyAccess().getWeakEntityEntityEStringParserRuleCall_4_0_1(), semanticObject.getWeakEntity());
		feeder.accept(grammarAccess.getIdentificationDependencyAccess().getRegularEntityRegularEntityParserRuleCall_6_0(), semanticObject.getRegularEntity());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=EString keyAttributes+=[Attribute|EString] keyAttributes+=[Attribute|EString]*)
	 */
	protected void sequence_Key(EObject context, Key semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (entity=[EntityConcept|EString] min=MinCardinality max=MaxCardinality role=EString?)
	 */
	protected void sequence_RegularEntity(EObject context, RegularEntity semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=EString entities+=RegularEntity entities+=RegularEntity* (relationshipAttributes+=Attribute relationshipAttributes+=Attribute*)?)
	 */
	protected void sequence_Relationship(EObject context, Relationship semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
}
