/** * Evaluate the condition and if not null, return it. * If it is null, return the other value. * @param state the expression state * @throws EvaluationException if the condition does not evaluate correctly * to a boolean or there is a problem executing the chosen alternative */ @Override public TypedValue getValueInternal(ExpressionState state) throws EvaluationException { TypedValue value = this.children[0].getValueInternal(state); // If this check is changed, the generateCode method will need changing too if (!StringUtils.isEmpty(value.getValue())) { return value; } else { TypedValue result = this.children[1].getValueInternal(state); computeExitTypeDescriptor(); return result; } }
valueIfNull = new NullLiteral(t.startPos + 1, t.endPos + 1); return new Elvis(t.startPos, t.endPos, expr, valueIfNull);
valueIfNull = new NullLiteral(toPos(t.startPos + 1, t.endPos + 1)); return new Elvis(toPos(t), expr, valueIfNull);
public Elvis { final static private Elvis INSTANCE = new Elvis(2); static public Elvis getInstance() { return INSTANCE; } final private AtomicInteger x; Elvis() { this(0); } Elvis(int x){ this.x = new AtomicInteger(x); } public int getX() { return this.x.get(); } public void setX(int x) {this.x.set(x); } public void sing(int x) { setX(x); System.out.println("Elvis singing.." + x); } }
/** * Evaluate the condition and if not null, return it. * If it is null, return the other value. * @param state the expression state * @throws EvaluationException if the condition does not evaluate correctly * to a boolean or there is a problem executing the chosen alternative */ @Override public TypedValue getValueInternal(ExpressionState state) throws EvaluationException { TypedValue value = this.children[0].getValueInternal(state); // If this check is changed, the generateCode method will need changing too if (!StringUtils.isEmpty(value.getValue())) { return value; } else { TypedValue result = this.children[1].getValueInternal(state); computeExitTypeDescriptor(); return result; } }
valueIfNull = new NullLiteral(toPos(t.startPos + 1, t.endPos + 1)); return new Elvis(toPos(t), expr, valueIfNull);
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { computeExitTypeDescriptor(); cf.enterCompilationScope(); this.children[0].generateCode(mv, cf);
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { computeExitTypeDescriptor(); cf.enterCompilationScope(); this.children[0].generateCode(mv, cf);
/** * Evaluate the condition and if not null, return it. * If it is null, return the other value. * @param state the expression state * @throws EvaluationException if the condition does not evaluate correctly * to a boolean or there is a problem executing the chosen alternative */ @Override public TypedValue getValueInternal(ExpressionState state) throws EvaluationException { TypedValue value = this.children[0].getValueInternal(state); // If this check is changed, the generateCode method will need changing too if (!StringUtils.isEmpty(value.getValue())) { return value; } else { TypedValue result = this.children[1].getValueInternal(state); computeExitTypeDescriptor(); return result; } }
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { computeExitTypeDescriptor(); cf.enterCompilationScope(); this.children[0].generateCode(mv, cf);