a2aproject / a2aproject/a2a-java

[Feat]: Clarify nullability and optionality of the spec API

Đang mở
#506 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Java
Star
490
Fork
172
Merge trung bình
1 ngày 6 giờ
Pull request đã merge (30 ngày)
55

Mô tả

### Is your feature request related to a problem? Please describe.

The `spec` API is not consistent with this expectation for the nullability and optionality of objects.

For example, the [Task](https://github.com/a2aproject/a2a-java/blob/cb084ec517f5511c45c0457850337b4b74431b10/spec/src/main/java/io/a2a/spec/Task.java#L68) class
will always instantiate its `history` and `artifact` with (potentially empty) collections while its `metatada` can be null.
The API should be consistent unless there is a good reason not to.
In that case, the `metadata` should also be an empty Map if the parameter is `null`.

For case where we want to record that a field can have a value or be null, we could also leverage `Optional`.
For example, in [TaskStatus](https://github.com/a2aproject/a2a-java/blob/cb084ec517f5511c45c0457850337b4b74431b10/spec/src/main/java/io/a2a/spec/TaskStatus.java#L46), the `message` is optional. We could make its type `Optional` to constrain its contract.

### Describe the solution you'd like

Update the spec API to:
* be consistent with the nullabitity of fields (especially collections)
* use the `Optional` type for optional fields
* update the javadoc when there is exception to this general rule

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.