Coverage Report - org.mule.context.notification.ListenerSubscriptionPair
 
Classes in this File Line Coverage Branch Coverage Complexity
ListenerSubscriptionPair
0%
0/28
0%
0/14
0
 
 1  
 /*
 2  
  * $Id: ListenerSubscriptionPair.java 20321 2010-11-24 15:21:24Z dfeist $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.context.notification;
 12  
 
 13  
 import org.mule.api.context.notification.ServerNotificationListener;
 14  
 import org.mule.util.ClassUtils;
 15  
 
 16  
 /**
 17  
  * A simple tuple that stores a listener with an optional subscription (used to match a resource ID).
 18  
  */
 19  
 public class ListenerSubscriptionPair
 20  
 {
 21  
 
 22  
     private ServerNotificationListener listener;
 23  0
     private String subscription = ServerNotificationManager.NULL_SUBSCRIPTION;
 24  0
     private boolean nullSubscription = true;
 25  
 
 26  
     /**
 27  
      * For config - must be constructed using the setters
 28  
      */
 29  
     public ListenerSubscriptionPair()
 30  
     {
 31  0
         super();
 32  0
     }
 33  
 
 34  
     public ListenerSubscriptionPair(ServerNotificationListener listener)
 35  0
     {
 36  0
         setListener(listener);
 37  0
     }
 38  
 
 39  
     public ListenerSubscriptionPair(ServerNotificationListener listener, String subscription)
 40  0
     {
 41  0
         setListener(listener);
 42  0
         setSubscription(subscription);
 43  0
     }
 44  
 
 45  
     public void setListener(ServerNotificationListener listener)
 46  
     {
 47  0
         this.listener = listener;
 48  0
     }
 49  
 
 50  
     public void setSubscription(String subscription)
 51  
     {
 52  0
         if (null != subscription)
 53  
         {
 54  0
             this.subscription = subscription;
 55  0
             nullSubscription = false;
 56  
         }
 57  0
     }
 58  
 
 59  
     public ServerNotificationListener getListener()
 60  
     {
 61  0
         return listener;
 62  
     }
 63  
 
 64  
     public String getSubscription()
 65  
     {
 66  0
         return subscription;
 67  
     }
 68  
 
 69  
     public boolean isNullSubscription()
 70  
     {
 71  0
         return nullSubscription;
 72  
     }
 73  
 
 74  
     @Override
 75  
     public int hashCode()
 76  
     {
 77  0
         return ClassUtils.hash(new Object[]{listener, subscription, nullSubscription});
 78  
     }
 79  
 
 80  
     @Override
 81  
     public boolean equals(Object obj)
 82  
     {
 83  0
         if (this == obj)
 84  
         {
 85  0
             return true;
 86  
         }
 87  0
         if (obj == null || getClass() != obj.getClass())
 88  
         {
 89  0
             return false;
 90  
         }
 91  
 
 92  0
         ListenerSubscriptionPair other = (ListenerSubscriptionPair) obj;
 93  0
         return ClassUtils.equal(listener, other.listener) 
 94  
             && ClassUtils.equal(subscription, other.subscription)
 95  
             && (nullSubscription == other.nullSubscription);
 96  
     }
 97  
 
 98  
     @Override
 99  
     public String toString()
 100  
     {
 101  0
         return "ListenerSubscriptionPair [listener=" + listener + ", subscription=" + subscription + "]";
 102  
     } 
 103  
 
 104  
 }