setFieldValue method

dynamic setFieldValue(
  1. int fieldID,
  2. Object? value
)
override

Set a field's value by fieldId. Primitive types must be "boxed" in the appropriate object wrapper type.

Implementation

setFieldValue(int fieldID, Object? value) {
  switch (fieldID) {
    case CODE:
      if (value == null) {
        unsetCode();
      } else {
        this.code = value as int?;
      }
      break;

    case LEADER:
      if (value == null) {
        unsetLeader();
      } else {
        this.leader = value as t_nebula.HostAddr?;
      }
      break;

    case ERROR_MSG:
      if (value == null) {
        unsetError_msg();
      } else {
        this.error_msg = value as Int8List?;
      }
      break;

    default:
      throw new ArgumentError("Field $fieldID doesn't exist!");
  }
}