use of cn.taketoday.expression.TypedValue in project today-infrastructure by TAKETODAY.
the class ReflectionHelperTests method testTypedValue.
@Test
public void testTypedValue() {
TypedValue tv1 = new TypedValue("hello");
TypedValue tv2 = new TypedValue("hello");
TypedValue tv3 = new TypedValue("bye");
assertThat(tv1.getTypeDescriptor().getType()).isEqualTo(String.class);
assertThat(tv1.toString()).isEqualTo("TypedValue: 'hello' of [java.lang.String]");
assertThat(tv2).isEqualTo(tv1);
assertThat(tv1).isEqualTo(tv2);
assertThat(tv3).isNotEqualTo(tv1);
assertThat(tv3).isNotEqualTo(tv2);
assertThat(tv1).isNotEqualTo(tv3);
assertThat(tv2).isNotEqualTo(tv3);
assertThat(tv2.hashCode()).isEqualTo(tv1.hashCode());
assertThat(tv3.hashCode()).isNotEqualTo(tv1.hashCode());
assertThat(tv3.hashCode()).isNotEqualTo(tv2.hashCode());
}
use of cn.taketoday.expression.TypedValue in project today-infrastructure by TAKETODAY.
the class SpelReproTests method SPR9994_bridgeMethods.
@Test
void SPR9994_bridgeMethods() throws Exception {
ReflectivePropertyAccessor accessor = new ReflectivePropertyAccessor();
StandardEvaluationContext context = new StandardEvaluationContext();
GenericImplementation target = new GenericImplementation();
accessor.write(context, target, "property", "1");
assertThat(target.value).isEqualTo(1);
TypedValue value = accessor.read(context, target, "property");
assertThat(value.getValue()).isEqualTo(1);
assertThat(value.getTypeDescriptor().getType()).isEqualTo(Integer.class);
assertThat(value.getTypeDescriptor().getAnnotations()).isNotEmpty();
}
use of cn.taketoday.expression.TypedValue in project today-infrastructure by TAKETODAY.
the class OpPlusTests method test_binaryPlusWithLeftStringOperand.
@Test
public void test_binaryPlusWithLeftStringOperand() {
ExpressionState expressionState = new ExpressionState(new StandardEvaluationContext());
StringLiteral n1 = new StringLiteral("\"number is \"", -1, -1, "\"number is \"");
LongLiteral n2 = new LongLiteral("123", -1, -1, 123);
OpPlus o = new OpPlus(-1, -1, n1, n2);
TypedValue value = o.getValueInternal(expressionState);
assertThat(value.getTypeDescriptor().getObjectType()).isEqualTo(String.class);
assertThat(value.getTypeDescriptor().getType()).isEqualTo(String.class);
assertThat(value.getValue()).isEqualTo("number is 123");
}
use of cn.taketoday.expression.TypedValue in project today-infrastructure by TAKETODAY.
the class Assign method getValueInternal.
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
TypedValue newValue = this.children[1].getValueInternal(state);
getChild(0).setValue(state, newValue.getValue());
return newValue;
}
use of cn.taketoday.expression.TypedValue in project today-infrastructure by TAKETODAY.
the class CompoundExpression method getValueInternal.
/**
* Evaluates a compound expression. This involves evaluating each piece in turn and the
* return value from each piece is the active context object for the subsequent piece.
*
* @param state the state in which the expression is being evaluated
* @return the final value from the last piece of the compound expression
*/
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
ValueRef ref = getValueRef(state);
TypedValue result = ref.getValue();
this.exitTypeDescriptor = this.children[this.children.length - 1].exitTypeDescriptor;
return result;
}
Aggregations