001    /**
002     * <copyright>
003     * </copyright>
004     *
005     * $Id$
006     */
007    package com.hammurapi.reasoning.spi.model.impl;
008    
009    import com.hammurapi.config.ConfigPackage;
010    
011    import com.hammurapi.reasoning.spi.model.ModelFactory;
012    import com.hammurapi.reasoning.spi.model.ModelPackage;
013    import com.hammurapi.reasoning.spi.model.Rule;
014    import com.hammurapi.reasoning.spi.model.RuleSet;
015    
016    import org.eclipse.emf.ecore.EAttribute;
017    import org.eclipse.emf.ecore.EClass;
018    import org.eclipse.emf.ecore.EPackage;
019    import org.eclipse.emf.ecore.EReference;
020    
021    import org.eclipse.emf.ecore.impl.EPackageImpl;
022    
023    /**
024     * <!-- begin-user-doc -->
025     * An implementation of the model <b>Package</b>.
026     * <!-- end-user-doc -->
027     * @generated
028     */
029    public class ModelPackageImpl extends EPackageImpl implements ModelPackage {
030            /**
031             * <!-- begin-user-doc -->
032             * <!-- end-user-doc -->
033             * @generated
034             */
035            private EClass ruleSetEClass = null;
036    
037            /**
038             * <!-- begin-user-doc -->
039             * <!-- end-user-doc -->
040             * @generated
041             */
042            private EClass ruleEClass = null;
043    
044            /**
045             * Creates an instance of the model <b>Package</b>, registered with
046             * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
047             * package URI value.
048             * <p>Note: the correct way to create the package is via the static
049             * factory method {@link #init init()}, which also performs
050             * initialization of the package, or returns the registered package,
051             * if one already exists.
052             * <!-- begin-user-doc -->
053             * <!-- end-user-doc -->
054             * @see org.eclipse.emf.ecore.EPackage.Registry
055             * @see com.hammurapi.reasoning.spi.model.ModelPackage#eNS_URI
056             * @see #init()
057             * @generated
058             */
059            private ModelPackageImpl() {
060                    super(eNS_URI, ModelFactory.eINSTANCE);
061            }
062    
063            /**
064             * <!-- begin-user-doc -->
065             * <!-- end-user-doc -->
066             * @generated
067             */
068            private static boolean isInited = false;
069    
070            /**
071             * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
072             * 
073             * <p>This method is used to initialize {@link ModelPackage#eINSTANCE} when that field is accessed.
074             * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
075             * <!-- begin-user-doc -->
076             * <!-- end-user-doc -->
077             * @see #eNS_URI
078             * @see #createPackageContents()
079             * @see #initializePackageContents()
080             * @generated
081             */
082            public static ModelPackage init() {
083                    if (isInited) return (ModelPackage)EPackage.Registry.INSTANCE.getEPackage(ModelPackage.eNS_URI);
084    
085                    // Obtain or create and register package
086                    ModelPackageImpl theModelPackage = (ModelPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof ModelPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new ModelPackageImpl());
087    
088                    isInited = true;
089    
090                    // Initialize simple dependencies
091                    ConfigPackage.eINSTANCE.eClass();
092    
093                    // Create package meta-data objects
094                    theModelPackage.createPackageContents();
095    
096                    // Initialize created meta-data
097                    theModelPackage.initializePackageContents();
098    
099                    // Mark meta-data to indicate it can't be changed
100                    theModelPackage.freeze();
101    
102      
103                    // Update the registry and return the package
104                    EPackage.Registry.INSTANCE.put(ModelPackage.eNS_URI, theModelPackage);
105                    return theModelPackage;
106            }
107    
108            /**
109             * <!-- begin-user-doc -->
110             * <!-- end-user-doc -->
111             * @generated
112             */
113            public EClass getRuleSet() {
114                    return ruleSetEClass;
115            }
116    
117            /**
118             * <!-- begin-user-doc -->
119             * <!-- end-user-doc -->
120             * @generated
121             */
122            public EReference getRuleSet_Rule() {
123                    return (EReference)ruleSetEClass.getEStructuralFeatures().get(0);
124            }
125    
126            /**
127             * <!-- begin-user-doc -->
128             * <!-- end-user-doc -->
129             * @generated
130             */
131            public EReference getRuleSet_Base() {
132                    return (EReference)ruleSetEClass.getEStructuralFeatures().get(1);
133            }
134    
135            /**
136             * <!-- begin-user-doc -->
137             * <!-- end-user-doc -->
138             * @generated
139             */
140            public EClass getRule() {
141                    return ruleEClass;
142            }
143    
144            /**
145             * <!-- begin-user-doc -->
146             * <!-- end-user-doc -->
147             * @generated
148             */
149            public EAttribute getRule_Priority() {
150                    return (EAttribute)ruleEClass.getEStructuralFeatures().get(0);
151            }
152    
153            /**
154             * <!-- begin-user-doc -->
155             * <!-- end-user-doc -->
156             * @generated
157             */
158            public ModelFactory getModelFactory() {
159                    return (ModelFactory)getEFactoryInstance();
160            }
161    
162            /**
163             * <!-- begin-user-doc -->
164             * <!-- end-user-doc -->
165             * @generated
166             */
167            private boolean isCreated = false;
168    
169            /**
170             * Creates the meta-model objects for the package.  This method is
171             * guarded to have no affect on any invocation but its first.
172             * <!-- begin-user-doc -->
173             * <!-- end-user-doc -->
174             * @generated
175             */
176            public void createPackageContents() {
177                    if (isCreated) return;
178                    isCreated = true;
179    
180                    // Create classes and their features
181                    ruleSetEClass = createEClass(RULE_SET);
182                    createEReference(ruleSetEClass, RULE_SET__RULE);
183                    createEReference(ruleSetEClass, RULE_SET__BASE);
184    
185                    ruleEClass = createEClass(RULE);
186                    createEAttribute(ruleEClass, RULE__PRIORITY);
187            }
188    
189            /**
190             * <!-- begin-user-doc -->
191             * <!-- end-user-doc -->
192             * @generated
193             */
194            private boolean isInitialized = false;
195    
196            /**
197             * Complete the initialization of the package and its meta-model.  This
198             * method is guarded to have no affect on any invocation but its first.
199             * <!-- begin-user-doc -->
200             * <!-- end-user-doc -->
201             * @generated
202             */
203            public void initializePackageContents() {
204                    if (isInitialized) return;
205                    isInitialized = true;
206    
207                    // Initialize package
208                    setName(eNAME);
209                    setNsPrefix(eNS_PREFIX);
210                    setNsURI(eNS_URI);
211    
212                    // Obtain other dependent packages
213                    ConfigPackage theConfigPackage = (ConfigPackage)EPackage.Registry.INSTANCE.getEPackage(ConfigPackage.eNS_URI);
214    
215                    // Create type parameters
216    
217                    // Set bounds for type parameters
218    
219                    // Add supertypes to classes
220                    ruleSetEClass.getESuperTypes().add(theConfigPackage.getNamedObjectDefinition());
221                    ruleEClass.getESuperTypes().add(theConfigPackage.getNamedObjectDefinition());
222    
223                    // Initialize classes and features; add operations and parameters
224                    initEClass(ruleSetEClass, RuleSet.class, "RuleSet", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
225                    initEReference(getRuleSet_Rule(), this.getRule(), null, "rule", null, 0, -1, RuleSet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
226                    initEReference(getRuleSet_Base(), this.getRuleSet(), null, "base", null, 0, -1, RuleSet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
227    
228                    initEClass(ruleEClass, Rule.class, "Rule", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
229                    initEAttribute(getRule_Priority(), ecorePackage.getEInt(), "priority", "0", 0, 1, Rule.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
230    
231                    // Create resource
232                    createResource(eNS_URI);
233            }
234    
235    } //ModelPackageImpl