Skip to content

Package: AndConditionImpl

AndConditionImpl

nameinstructionbranchcomplexitylinemethod
AndConditionImpl()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
eGet(int, boolean, boolean)
M: 6 C: 5
45%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 2
67%
M: 0 C: 1
100%
eInverseRemove(InternalEObject, int, NotificationChain)
M: 15 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
eIsSet(int)
M: 4 C: 13
76%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 1
100%
eSet(int, Object)
M: 17 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
eStaticClass()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
eUnset(int)
M: 10 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
evaluate(EObject)
M: 0 C: 22
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
evaluateChangedValues(EObject, Map)
M: 8 C: 42
84%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 2 C: 9
82%
M: 0 C: 1
100%
getConditions()
M: 0 C: 14
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * EclipseSource Munich GmbH - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.spi.rule.model.impl;
15:
16: import java.util.Collection;
17: import java.util.Map;
18:
19: import org.eclipse.emf.common.notify.NotificationChain;
20: import org.eclipse.emf.common.util.EList;
21: import org.eclipse.emf.ecore.EClass;
22: import org.eclipse.emf.ecore.EObject;
23: import org.eclipse.emf.ecore.EStructuralFeature.Setting;
24: import org.eclipse.emf.ecore.InternalEObject;
25: import org.eclipse.emf.ecore.util.EObjectContainmentEList;
26: import org.eclipse.emf.ecore.util.InternalEList;
27: import org.eclipse.emf.ecp.view.spi.rule.model.AndCondition;
28: import org.eclipse.emf.ecp.view.spi.rule.model.Condition;
29: import org.eclipse.emf.ecp.view.spi.rule.model.LeafCondition;
30: import org.eclipse.emf.ecp.view.spi.rule.model.RulePackage;
31: import org.eclipse.emf.ecp.view.spi.rule.model.util.ConditionEvaluationUtil;
32:
33: /**
34: * <!-- begin-user-doc -->
35: * An implementation of the model object '<em><b>And Condition</b></em>'.
36: *
37: * @since 1.2
38: * <!-- end-user-doc -->
39: * <p>
40: * The following features are implemented:
41: * </p>
42: * <ul>
43: * <li>{@link org.eclipse.emf.ecp.view.spi.rule.model.impl.AndConditionImpl#getConditions
44: * <em>Conditions</em>}</li>
45: * </ul>
46: *
47: * @generated
48: */
49: public class AndConditionImpl extends ConditionImpl implements AndCondition {
50:         /**
51:          * The cached value of the '{@link #getConditions() <em>Conditions</em>}' containment reference list.
52:          * <!-- begin-user-doc -->
53:          * <!-- end-user-doc -->
54:          *
55:          * @see #getConditions()
56:          * @generated
57:          * @ordered
58:          */
59:         protected EList<Condition> conditions;
60:
61:         /**
62:          * <!-- begin-user-doc -->
63:          * <!-- end-user-doc -->
64:          *
65:          * @generated
66:          */
67:         protected AndConditionImpl() {
68:                 super();
69:         }
70:
71:         /**
72:          * <!-- begin-user-doc -->
73:          * <!-- end-user-doc -->
74:          *
75:          * @generated
76:          */
77:         @Override
78:         protected EClass eStaticClass() {
79:                 return RulePackage.Literals.AND_CONDITION;
80:         }
81:
82:         /**
83:          * <!-- begin-user-doc -->
84:          * <!-- end-user-doc -->
85:          *
86:          * @generated
87:          */
88:         @Override
89:         public EList<Condition> getConditions() {
90:•                if (conditions == null) {
91:                         conditions = new EObjectContainmentEList<Condition>(Condition.class, this,
92:                                 RulePackage.AND_CONDITION__CONDITIONS);
93:                 }
94:                 return conditions;
95:         }
96:
97:         /**
98:          * <!-- begin-user-doc -->
99:          * <!-- end-user-doc -->
100:          *
101:          * @generated
102:          */
103:         @Override
104:         public NotificationChain eInverseRemove(InternalEObject otherEnd,
105:                 int featureID, NotificationChain msgs) {
106:•                switch (featureID) {
107:                 case RulePackage.AND_CONDITION__CONDITIONS:
108:                         return ((InternalEList<?>) getConditions()).basicRemove(otherEnd, msgs);
109:                 }
110:                 return super.eInverseRemove(otherEnd, featureID, msgs);
111:         }
112:
113:         /**
114:          * <!-- begin-user-doc -->
115:          * <!-- end-user-doc -->
116:          *
117:          * @generated
118:          */
119:         @Override
120:         public Object eGet(int featureID, boolean resolve, boolean coreType) {
121:•                switch (featureID) {
122:                 case RulePackage.AND_CONDITION__CONDITIONS:
123:                         return getConditions();
124:                 }
125:                 return super.eGet(featureID, resolve, coreType);
126:         }
127:
128:         /**
129:          * <!-- begin-user-doc -->
130:          * <!-- end-user-doc -->
131:          *
132:          * @generated
133:          */
134:         @SuppressWarnings("unchecked")
135:         @Override
136:         public void eSet(int featureID, Object newValue) {
137:•                switch (featureID) {
138:                 case RulePackage.AND_CONDITION__CONDITIONS:
139:                         getConditions().clear();
140:                         getConditions().addAll((Collection<? extends Condition>) newValue);
141:                         return;
142:                 }
143:                 super.eSet(featureID, newValue);
144:         }
145:
146:         /**
147:          * <!-- begin-user-doc -->
148:          * <!-- end-user-doc -->
149:          *
150:          * @generated
151:          */
152:         @Override
153:         public void eUnset(int featureID) {
154:•                switch (featureID) {
155:                 case RulePackage.AND_CONDITION__CONDITIONS:
156:                         getConditions().clear();
157:                         return;
158:                 }
159:                 super.eUnset(featureID);
160:         }
161:
162:         /**
163:          * <!-- begin-user-doc -->
164:          * <!-- end-user-doc -->
165:          *
166:          * @generated
167:          */
168:         @Override
169:         public boolean eIsSet(int featureID) {
170:•                switch (featureID) {
171:                 case RulePackage.AND_CONDITION__CONDITIONS:
172:•                        return conditions != null && !conditions.isEmpty();
173:                 }
174:                 return super.eIsSet(featureID);
175:         }
176:
177:         /**
178:          * {@inheritDoc}
179:          *
180:          * @see org.eclipse.emf.ecp.view.spi.rule.model.Condition#evaluate(org.eclipse.emf.ecore.EObject)
181:          * @since 1.9
182:          */
183:         @Override
184:         public boolean evaluate(EObject domainModel) {
185:                 boolean result = true;
186:•                for (final Condition innerCondition : getConditions()) {
187:                         result &= innerCondition.evaluate(domainModel);
188:                 }
189:                 return result;
190:         }
191:
192:         /**
193:          * {@inheritDoc}
194:          *
195:          * @see org.eclipse.emf.ecp.view.spi.rule.model.Condition#evaluateChangedValues(org.eclipse.emf.ecore.EObject,
196:          * java.util.Map)
197:          * @since 1.9
198:          */
199:         @Override
200:         public boolean evaluateChangedValues(EObject domainModel, Map<Setting, Object> possibleNewValues) {
201:                 boolean result = true;
202:•                for (final Condition innerCondition : getConditions()) {
203:•                        if (LeafCondition.class.isInstance(innerCondition)) {
204:                                 if (ConditionEvaluationUtil.isLeafConditionForSetting(LeafCondition.class.cast(innerCondition),
205:•                                        domainModel, possibleNewValues)) {
206:                                         result &= innerCondition.evaluateChangedValues(domainModel, possibleNewValues);
207:                                 } else {
208:                                         result &= innerCondition.evaluate(domainModel);
209:                                 }
210:                         } else {
211:                                 result &= innerCondition.evaluateChangedValues(domainModel, possibleNewValues);
212:                         }
213:                 }
214:                 return result;
215:         }
216:
217: } // AndConditionImpl