Coverage Summary for Class: SubscriberExceptionContext (com.google.common.eventbus)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| SubscriberExceptionContext | 0% (0/1) | 0% (0/5) | 0% (0/9) |
1 /* 2 * Copyright (C) 2013 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 java.lang.reflect.Method; 20 21 /** 22 * Context for an exception thrown by a subscriber. 23 * 24 * @since 16.0 25 */ 26 @ElementTypesAreNonnullByDefault 27 public class SubscriberExceptionContext { 28 private final EventBus eventBus; 29 private final Object event; 30 private final Object subscriber; 31 private final Method subscriberMethod; 32 33 /** 34 * @param eventBus The {@link EventBus} that handled the event and the subscriber. Useful for 35 * broadcasting a new event based on the error. 36 * @param event The event object that caused the subscriber to throw. 37 * @param subscriber The source subscriber context. 38 * @param subscriberMethod the subscribed method. 39 */ 40 SubscriberExceptionContext( 41 EventBus eventBus, Object event, Object subscriber, Method subscriberMethod) { 42 this.eventBus = checkNotNull(eventBus); 43 this.event = checkNotNull(event); 44 this.subscriber = checkNotNull(subscriber); 45 this.subscriberMethod = checkNotNull(subscriberMethod); 46 } 47 48 /** 49 * @return The {@link EventBus} that handled the event and the subscriber. Useful for broadcasting 50 * a new event based on the error. 51 */ 52 public EventBus getEventBus() { 53 return eventBus; 54 } 55 56 /** @return The event object that caused the subscriber to throw. */ 57 public Object getEvent() { 58 return event; 59 } 60 61 /** @return The object context that the subscriber was called on. */ 62 public Object getSubscriber() { 63 return subscriber; 64 } 65 66 /** @return The subscribed method that threw the exception. */ 67 public Method getSubscriberMethod() { 68 return subscriberMethod; 69 } 70 }