google / google/auto

Null default for empty collections is annoying

Open
#451 6 comments 0 reactions 0 assignees View on GitHub
Component: value P3 type=addition
Dominant language
Java
Stars
10.6k
Forks
1.2k
Avg merge
6h 32m
Merged PRs (30d)
13

Description

It's very annoying to have to write:

```java
@AutoValue.Builder
public abstract static class Builder {
public static Builder create() {
return new AutoValue_MyType.Builder()
.setCharges(emptyList())
.setPayments(emptyList())
.setParticipants(emptyList())
.setTags(emptyList());
}
```

just to ensure that a field `@Nonnull public abstract List getCharges()` defaults to empty-list on the builder instead of null. It would be nice to have some way to specify a default for non-primitive non-null types.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.