Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data field of type Optional<Map<String, Object>> #323

Open
gquintana opened this issue Sep 7, 2023 · 0 comments
Open

data field of type Optional<Map<String, Object>> #323

gquintana opened this issue Sep 7, 2023 · 0 comments

Comments

@gquintana
Copy link

gquintana commented Sep 7, 2023

Having a field of type Optional<Map<String, Object>> does not make sense to me,
When no data has been set, returning a empty Map instead of an empty Optional is far simpler and clearer.
Wrapping a Collection in an Optional is not considered as a good practice:

At least could you add helper methods like

    public Map<String, Object> getDataMap() {
        return getData().orElse(Collections.emptyMap());
    }
    public Optional<Object> getData(String key) {
       return getData().map(data -> data.get(key));
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant