brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: fix dto.entries repetition errors...
Date Mon, 03 Nov 2014 15:00:24 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/289#discussion_r19737220
  
    --- Diff: core/src/main/java/brooklyn/catalog/internal/CatalogDto.java ---
    @@ -178,4 +182,33 @@ public String toString() {
                     .toString();
         }
     
    +    // temporary fix for issue where entries might not be unique
    +    Iterable<CatalogItemDtoAbstract<?, ?>> getUniqueEntries() {
    +        if (entries==null) return null;
    +        Map<String, CatalogItemDtoAbstract<?, ?>> result = getEntriesMap();
    +        return result.values();
    +    }
    +
    +    private Map<String, CatalogItemDtoAbstract<?, ?>> getEntriesMap() {
    +        if (entries==null) return null;
    --- End diff --
    
    Personal preference: I'm a big fan of not returning null when an `ImmutableMap.of()` means
the same thing. Same for returning an `ImmutableList.of()` from `getUniqueEntries()`. It saves
null guards all over the place, and NPEs when someone forgets to guard against null.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message