001    /**
002     * <copyright>
003     * </copyright>
004     *
005     * $Id$
006     */
007    package com.hammurapi.reasoning.spi.model.impl;
008    
009    import com.hammurapi.config.impl.NamedObjectDefinitionImpl;
010    
011    import com.hammurapi.reasoning.spi.model.ModelPackage;
012    import com.hammurapi.reasoning.spi.model.Rule;
013    
014    import org.eclipse.emf.common.notify.Notification;
015    
016    import org.eclipse.emf.ecore.EClass;
017    
018    import org.eclipse.emf.ecore.impl.ENotificationImpl;
019    
020    /**
021     * <!-- begin-user-doc -->
022     * An implementation of the model object '<em><b>Rule</b></em>'.
023     * <!-- end-user-doc -->
024     * <p>
025     * The following features are implemented:
026     * <ul>
027     *   <li>{@link com.hammurapi.reasoning.spi.model.impl.RuleImpl#getPriority <em>Priority</em>}</li>
028     * </ul>
029     * </p>
030     *
031     * @generated
032     */
033    public class RuleImpl extends NamedObjectDefinitionImpl implements Rule {
034            /**
035             * The default value of the '{@link #getPriority() <em>Priority</em>}' attribute.
036             * <!-- begin-user-doc -->
037             * <!-- end-user-doc -->
038             * @see #getPriority()
039             * @generated
040             * @ordered
041             */
042            protected static final int PRIORITY_EDEFAULT = 0;
043    
044            /**
045             * The cached value of the '{@link #getPriority() <em>Priority</em>}' attribute.
046             * <!-- begin-user-doc -->
047             * <!-- end-user-doc -->
048             * @see #getPriority()
049             * @generated
050             * @ordered
051             */
052            protected int priority = PRIORITY_EDEFAULT;
053    
054            /**
055             * <!-- begin-user-doc -->
056             * <!-- end-user-doc -->
057             * @generated
058             */
059            protected RuleImpl() {
060                    super();
061            }
062    
063            /**
064             * <!-- begin-user-doc -->
065             * <!-- end-user-doc -->
066             * @generated
067             */
068            @Override
069            protected EClass eStaticClass() {
070                    return ModelPackage.Literals.RULE;
071            }
072    
073            /**
074             * <!-- begin-user-doc -->
075             * <!-- end-user-doc -->
076             * @generated
077             */
078            public int getPriority() {
079                    return priority;
080            }
081    
082            /**
083             * <!-- begin-user-doc -->
084             * <!-- end-user-doc -->
085             * @generated
086             */
087            public void setPriority(int newPriority) {
088                    int oldPriority = priority;
089                    priority = newPriority;
090                    if (eNotificationRequired())
091                            eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.RULE__PRIORITY, oldPriority, priority));
092            }
093    
094            /**
095             * <!-- begin-user-doc -->
096             * <!-- end-user-doc -->
097             * @generated
098             */
099            @Override
100            public Object eGet(int featureID, boolean resolve, boolean coreType) {
101                    switch (featureID) {
102                            case ModelPackage.RULE__PRIORITY:
103                                    return getPriority();
104                    }
105                    return super.eGet(featureID, resolve, coreType);
106            }
107    
108            /**
109             * <!-- begin-user-doc -->
110             * <!-- end-user-doc -->
111             * @generated
112             */
113            @Override
114            public void eSet(int featureID, Object newValue) {
115                    switch (featureID) {
116                            case ModelPackage.RULE__PRIORITY:
117                                    setPriority((Integer)newValue);
118                                    return;
119                    }
120                    super.eSet(featureID, newValue);
121            }
122    
123            /**
124             * <!-- begin-user-doc -->
125             * <!-- end-user-doc -->
126             * @generated
127             */
128            @Override
129            public void eUnset(int featureID) {
130                    switch (featureID) {
131                            case ModelPackage.RULE__PRIORITY:
132                                    setPriority(PRIORITY_EDEFAULT);
133                                    return;
134                    }
135                    super.eUnset(featureID);
136            }
137    
138            /**
139             * <!-- begin-user-doc -->
140             * <!-- end-user-doc -->
141             * @generated
142             */
143            @Override
144            public boolean eIsSet(int featureID) {
145                    switch (featureID) {
146                            case ModelPackage.RULE__PRIORITY:
147                                    return priority != PRIORITY_EDEFAULT;
148                    }
149                    return super.eIsSet(featureID);
150            }
151    
152            /**
153             * <!-- begin-user-doc -->
154             * <!-- end-user-doc -->
155             * @generated
156             */
157            @Override
158            public String toString() {
159                    if (eIsProxy()) return super.toString();
160    
161                    StringBuffer result = new StringBuffer(super.toString());
162                    result.append(" (priority: ");
163                    result.append(priority);
164                    result.append(')');
165                    return result.toString();
166            }
167    
168    } //RuleImpl