Coverage Summary for Class: DeadEvent (com.google.common.eventbus)

Class Class, % Method, % Line, %
DeadEvent 0% (0/1) 0% (0/4) 0% (0/6)


1 /* 2  * Copyright (C) 2007 The Guava Authors 3  * 4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5  * in compliance with the License. You may obtain a copy of the License at 6  * 7  * http://www.apache.org/licenses/LICENSE-2.0 8  * 9  * Unless required by applicable law or agreed to in writing, software distributed under the License 10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11  * or implied. See the License for the specific language governing permissions and limitations under 12  * the License. 13  */ 14  15 package com.google.common.eventbus; 16  17 import static com.google.common.base.Preconditions.checkNotNull; 18  19 import com.google.common.base.MoreObjects; 20  21 /** 22  * Wraps an event that was posted, but which had no subscribers and thus could not be delivered. 23  * 24  * <p>Registering a DeadEvent subscriber is useful for debugging or logging, as it can detect 25  * misconfigurations in a system's event distribution. 26  * 27  * @author Cliff Biffle 28  * @since 10.0 29  */ 30 @ElementTypesAreNonnullByDefault 31 public class DeadEvent { 32  33  private final Object source; 34  private final Object event; 35  36  /** 37  * Creates a new DeadEvent. 38  * 39  * @param source object broadcasting the DeadEvent (generally the {@link EventBus}). 40  * @param event the event that could not be delivered. 41  */ 42  public DeadEvent(Object source, Object event) { 43  this.source = checkNotNull(source); 44  this.event = checkNotNull(event); 45  } 46  47  /** 48  * Returns the object that originated this event (<em>not</em> the object that originated the 49  * wrapped event). This is generally an {@link EventBus}. 50  * 51  * @return the source of this event. 52  */ 53  public Object getSource() { 54  return source; 55  } 56  57  /** 58  * Returns the wrapped, 'dead' event, which the system was unable to deliver to any registered 59  * subscriber. 60  * 61  * @return the 'dead' event that could not be delivered. 62  */ 63  public Object getEvent() { 64  return event; 65  } 66  67  @Override 68  public String toString() { 69  return MoreObjects.toStringHelper(this).add("source", source).add("event", event).toString(); 70  } 71 }