diff --git a/src/main/java/gr/uom/java/xmi/decomposition/TernaryOperatorExpression.java b/src/main/java/gr/uom/java/xmi/decomposition/TernaryOperatorExpression.java index 8d9e0cf446..c198f6fa11 100644 --- a/src/main/java/gr/uom/java/xmi/decomposition/TernaryOperatorExpression.java +++ b/src/main/java/gr/uom/java/xmi/decomposition/TernaryOperatorExpression.java @@ -50,12 +50,15 @@ public String getExpression() { } public Replacement makeReplacementWithTernaryOnTheRight(String statement, Map parameterToArgumentMap) { - if(getElseExpression().getString().equals(statement)) { + if(getElseExpression().getString().equals(statement) || getElseExpression().getString().equals(statement + ".get()")) { return new Replacement(statement, getElseExpression().getString(), ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_ELSE); } - if(getThenExpression().getString().equals(statement)) { + if(getThenExpression().getString().equals(statement) || getThenExpression().getString().equals(statement + ".get()")) { return new Replacement(statement, getThenExpression().getString(), ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_THEN); } + if(getCondition().getString().equals(statement) || getCondition().getString().equals(statement + ".get()")) { + return new Replacement(statement, getCondition().getString(), ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_CONDITION); + } String temp = new String(statement); for(String key : parameterToArgumentMap.keySet()) { if(!key.equals(parameterToArgumentMap.get(key))) { @@ -69,17 +72,23 @@ public Replacement makeReplacementWithTernaryOnTheRight(String statement, Map parameterToArgumentMap) { - if(getElseExpression().getString().equals(statement)) { + if(getElseExpression().getString().equals(statement) || getElseExpression().getString().equals(statement + ".get()")) { return new Replacement(getElseExpression().getString(), statement, ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_ELSE); } - if(getThenExpression().getString().equals(statement)) { + if(getThenExpression().getString().equals(statement) || getThenExpression().getString().equals(statement + ".get()")) { return new Replacement(getThenExpression().getString(), statement, ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_THEN); } + if(getCondition().getString().equals(statement) || getCondition().getString().equals(statement + ".get()")) { + return new Replacement(getCondition().getString(), statement, ReplacementType.EXPRESSION_REPLACED_WITH_TERNARY_CONDITION); + } String temp = new String(statement); for(String key : parameterToArgumentMap.keySet()) { if(!key.equals(parameterToArgumentMap.get(key))) { @@ -93,6 +102,9 @@ public Replacement makeReplacementWithTernaryOnTheLeft(String statement, Map