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