You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by aledsage <gi...@git.apache.org> on 2014/11/03 16:00:24 UTC

[GitHub] incubator-brooklyn pull request: fix dto.entries repetition errors...

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.
---