Coverage Report - org.mule.routing.filters.PayloadTypeFilter
 
Classes in this File Line Coverage Branch Coverage Complexity
PayloadTypeFilter
100%
11/11
100%
2/2
1
 
 1  
 /*
 2  
  * $Id: PayloadTypeFilter.java 11477 2008-03-22 00:18:50Z rossmason $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.routing.filters;
 12  
 
 13  
 import org.mule.api.MuleMessage;
 14  
 import org.mule.api.routing.filter.Filter;
 15  
 import org.mule.util.ClassUtils;
 16  
 
 17  
 /**
 18  
  * <code>PayloadTypeFilter</code> filters based on the type of the object received.
 19  
  */
 20  
 
 21  
 public class PayloadTypeFilter implements Filter
 22  
 {
 23  
     private Class expectedType;
 24  
 
 25  
     public PayloadTypeFilter()
 26  
     {
 27  6
         super();
 28  6
     }
 29  
 
 30  
     public PayloadTypeFilter(String expectedType) throws ClassNotFoundException
 31  
     {
 32  8
         this(ClassUtils.loadClass(expectedType, PayloadTypeFilter.class));
 33  8
     }
 34  
 
 35  
     public PayloadTypeFilter(Class expectedType)
 36  56
     {
 37  56
         this.expectedType = expectedType;
 38  56
     }
 39  
 
 40  
     public boolean accept(MuleMessage message)
 41  
     {
 42  122
         return (expectedType != null ? expectedType.isAssignableFrom(message.getPayload().getClass()) : false);
 43  
     }
 44  
 
 45  
     public Class getExpectedType()
 46  
     {
 47  32
         return expectedType;
 48  
     }
 49  
 
 50  
     public void setExpectedType(Class expectedType)
 51  
     {
 52  8
         this.expectedType = expectedType;
 53  8
     }
 54  
 
 55  
 }