Add read and remove methods to ApplicationProperties#1765
Add read and remove methods to ApplicationProperties#1765rodmibielli wants to merge 5 commits intospring-io:mainfrom
Conversation
Signed-off-by: Rodrigo Mibielli Peixoto <rodrigo.mibielli@gmail.com>
Signed-off-by: Rodrigo Mibielli Peixoto <rodrigo.mibielli@gmail.com>
…cation Properties. Signed-off-by: Rodrigo Mibielli Peixoto <rodrigo.mibielli@gmail.com>
mhalbritter
left a comment
There was a problem hiding this comment.
Hi @rodmibielli , thanks for the PR. I've left some comments for your consideration.
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| import javax.annotation.Nullable; |
There was a problem hiding this comment.
That's the wrong nullable. We use JSpecify's @Nullable.
| add(key, (Object) value); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
This JavaDoc is very verbose. Please tone it down a bit, like the existing JavaDoc in the codebase.
| void keyNotFoundGetPropertyValue() { | ||
| ApplicationProperties properties = new ApplicationProperties(); | ||
| properties.add("test", "123"); | ||
| Object value = properties.get("teste"); |
There was a problem hiding this comment.
Please use something more easily differentiable from test, e.g. not-found.
| void getPropertyValueThrowsClassCastException() { | ||
| ApplicationProperties properties = new ApplicationProperties(); | ||
| properties.add("test", 123L); | ||
| assertThatThrownBy(() -> properties.get("test", Integer.class)).isInstanceOf(ClassCastException.class); |
There was a problem hiding this comment.
Please use assertThatExceptionOfType(ClassCastException.class).isThrownBy(...).
| void keyNotFoundGetPropertyValueCast() { | ||
| ApplicationProperties properties = new ApplicationProperties(); | ||
| properties.add("test", 123.4); | ||
| Double value = properties.get("teste", Double.class); |
There was a problem hiding this comment.
Please use something more easily differentiable from test, e.g. not-found.
| ApplicationProperties properties = new ApplicationProperties(); | ||
| properties.add("test", "value"); | ||
| boolean removed = properties.remove("test"); | ||
| assertThat(removed).isTrue(); |
There was a problem hiding this comment.
Please also assert that the key is indeed gone.
Signed-off-by: Rodrigo Mibielli Peixoto <rodrigo.mibielli@gmail.com>
Signed-off-by: Rodrigo Mibielli Peixoto <rodrigo.mibielli@gmail.com>
|
Hey @mhalbritter thank you for the feedback! |
See gh-1765 Signed-off-by: Rodrigo Mibielli Peixoto <rodrigo.mibielli@gmail.com>
|
Thanks @rodmibielli ! |
|
Btw, the next time you open a PR, please do so by creating a branch in your fork and create a PR from that. This way we can merge the PR in a way that GitHub actually shows the PR as merged, not as "red closed". Thanks! |
|
Oh, sorry for that! Thanks!
Rodrigo.
…-------------------------------------------------------------------------------------------------
"Um país se faz com homens e livros" - Monteiro Lobato.
Em seg., 16 de mar. de 2026, 11:13, Moritz Halbritter <
***@***.***> escreveu:
*mhalbritter* left a comment (spring-io/initializr#1765)
<#1765 (comment)>
Btw, the next time you open a PR, please do so by creating a branch in
your fork and create a PR from that. This way we can merge the PR in a way
that GitHub actually shows the PR as merged, not as "red closed". Thanks!
—
Reply to this email directly, view it on GitHub
<#1765 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACY5DUI4OLW5C3HTDBNXSET4RADXNAVCNFSM6AAAAACWSQN3K2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DANRXHE2TQMJXHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Added the following methods to
ApplicationProperties:@Nullable Object get(String key)@Nullable T get(String key, Class<T> clazz)which throws if it's the wrong typeboolean contains(String key)boolean remove(String key)which returns true if something has been removed