Commit 595a391
authored
Return an empty collection instead of null (#2530)
* Return an empty collection instead of null
The method `get<MemberName>OrEmpty()` for collections, either lists or
maps, was supposed to return an empty collection when the collection
was not set, instead of null, but somehow we missed to add this
expected behavior. This change fixes this, if the collection was not
set we return either `Collections.emptyList()` or
`Collections.emptyMap()` depending on the collection type instead of
`null`. The user can still find whether the value was set by using the
`Optional<...> get<MemberName>()` variant that returns en empty
optional when the collection was not set.1 parent 2be4f24 commit 595a391
1 file changed
Lines changed: 7 additions & 2 deletions
File tree
- smithy-trait-codegen/src/main/java/software/amazon/smithy/traitcodegen/generators
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
139 | | - | |
| 140 | + | |
| 141 | + | |
140 | 142 | | |
141 | 143 | | |
142 | 144 | | |
143 | 145 | | |
144 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
145 | 150 | | |
146 | 151 | | |
147 | 152 | | |
| |||
0 commit comments