assign method

Object? assign(
  1. ExpressionState state,
  2. Object? valueSupplier()
)

Assigns the value from valueSupplier to this node and returns it (Spring's setValueInternal): = and Expression.setValue.

The target is resolved before the value is computed; nodes that cannot be assigned throw SpelMessage.setvalueNotSupported.

Implementation

Object? assign(ExpressionState state, Object? Function() valueSupplier) {
  if (!isAssignable) {
    throw state.error(SpelMessage.setvalueNotSupported, start, [runtimeType]);
  }
  final ref = getValueRef(state);
  final value = valueSupplier();
  ref.setValue(value);
  return value;
}