2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.utils;
11 import akka.actor.ActorRef;
12 import com.google.common.base.Predicate;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
16 public class ConditionalProbe {
17 private final ActorRef actorRef;
18 private final Predicate predicate;
19 Logger log = LoggerFactory.getLogger(ConditionalProbe.class);
21 public ConditionalProbe(ActorRef actorRef, Predicate predicate) {
22 this.actorRef = actorRef;
23 this.predicate = predicate;
26 public void tell(Object message, ActorRef sender){
27 if(predicate.apply(message)) {
28 log.info("sending message to probe {}", message);
29 actorRef.tell(message, sender);