jcabrerizo commented on a change in pull request #1297: URL: https://github.com/apache/brooklyn-server/pull/1297#discussion_r800516429
########## File path: utils/common/src/main/java/org/apache/brooklyn/util/collections/CollectionFunctionals.java ########## @@ -119,6 +115,35 @@ public T apply(Iterable<? extends T> input) { @Override public String toString() { return "firstElementFunction"; } } + public static class AllEqualsFunction implements Function<Iterable<?>, Comparable<?>> { + private final Comparable<?> value; + + public AllEqualsFunction(Comparable<?> value) { + if (Objects.isNull(value)) { + throw new IllegalArgumentException("The value to compare all to must be defined"); + } + this.value = value; + } + + @Override + public Boolean apply(@Nullable Iterable<?> input) { + if (Objects.isNull(input) || Iterables.isEmpty(input)) return null; Review comment: Agree, but for me, it looks like we need to have flag for do not evaluate unless is not empty or not null. Yes, the use of `brooklyn:attributeWhenReady` will help, but if only the function used, the transformer will return null if the source sensor is not returning a false value. I'm happy to approve but please, add some comments explaining why it will return `null` comparing with an empty collection -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brooklyn.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org