public IfThenElseStringFeature( BooleanFeature<T> condition, StringFeature<T> thenFeature, StringFeature<T> elseFeature) { super(); this.condition = condition; this.thenFeature = thenFeature; this.elseFeature = elseFeature; this.setName( "IfThenElse(" + condition.getName() + "," + thenFeature.getName() + "," + elseFeature.getName() + ")"); }
@Override protected FeatureResult<String> checkInternal(T context, RuntimeEnvironment env) { FeatureResult<String> featureResult = null; FeatureResult<Boolean> conditionResult = condition.check(context, env); if (conditionResult != null) { boolean conditionOutcome = conditionResult.getOutcome(); if (conditionOutcome) { FeatureResult<String> thenFeatureResult = thenFeature.check(context, env); if (thenFeatureResult != null) { String result = thenFeatureResult.getOutcome(); featureResult = this.generateResult(result); } } else { FeatureResult<String> elseFeatureResult = elseFeature.check(context, env); if (elseFeatureResult != null) { String result = elseFeatureResult.getOutcome(); featureResult = this.generateResult(result); } } } return featureResult; }