Return-Path: X-Original-To: apmail-brooklyn-dev-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B314411A94 for ; Fri, 29 Aug 2014 11:42:40 +0000 (UTC) Received: (qmail 36933 invoked by uid 500); 29 Aug 2014 11:42:40 -0000 Delivered-To: apmail-brooklyn-dev-archive@brooklyn.apache.org Received: (qmail 36896 invoked by uid 500); 29 Aug 2014 11:42:40 -0000 Mailing-List: contact dev-help@brooklyn.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.incubator.apache.org Delivered-To: mailing list dev@brooklyn.incubator.apache.org Received: (qmail 36885 invoked by uid 99); 29 Aug 2014 11:42:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Aug 2014 11:42:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 29 Aug 2014 11:42:17 +0000 Received: (qmail 35534 invoked by uid 99); 29 Aug 2014 11:42:15 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Aug 2014 11:42:15 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9AF6E9561EC; Fri, 29 Aug 2014 11:42:14 +0000 (UTC) From: neykov To: dev@brooklyn.incubator.apache.org Reply-To: dev@brooklyn.incubator.apache.org References: In-Reply-To: Subject: [GitHub] incubator-brooklyn pull request: Sensors chained for service up Content-Type: text/plain Message-Id: <20140829114214.9AF6E9561EC@tyr.zones.apache.org> Date: Fri, 29 Aug 2014 11:42:14 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Github user neykov commented on a diff in the pull request: https://github.com/apache/incubator-brooklyn/pull/131#discussion_r16893523 --- Diff: utils/common/src/main/java/brooklyn/util/guava/IfFunctions.java --- @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package brooklyn.util.guava; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.google.common.annotations.Beta; +import com.google.common.base.Function; +import com.google.common.base.Functions; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.base.Supplier; + +/** Utilities for building {@link Function} instances which return specific values + * (or {@link Supplier} or {@link Function} instances) when certain predicates are satisfied, + * tested in order and returning the first matching, + * with support for an "else" default value if none are satisfied (null by default). */ +public class IfFunctions { + + public static IfFunctionBuilder newInstance(Class testType, Class returnType) { + return new IfFunctionBuilder(); + } + + public static IfFunctionBuilderApplyingFirst ifPredicate(Predicate test) { + return new IfFunctionBuilderApplyingFirst(test); + } + public static IfFunctionBuilderApplyingFirst ifEquals(I test) { + return ifPredicate(Predicates.equalTo(test)); + } + public static IfFunctionBuilderApplyingFirst ifNotEquals(I test) { --- End diff -- Remove the O type parameter, unused (all three methods). --- 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. ---