Coverage Report - org.dozer.event.DozerEventManager
 
Classes in this File Line Coverage Branch Coverage Complexity
DozerEventManager
57%
11/19
44%
4/9
4.5
DozerEventManager$1
100%
1/1
N/A
4.5
 
 1  
 /**
 2  
  * Copyright 2005-2013 Dozer Project
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.dozer.event;
 17  
 
 18  
 import org.dozer.DozerEventListener;
 19  
 import org.dozer.util.MappingUtils;
 20  
 
 21  
 import java.util.List;
 22  
 
 23  
 
 24  
 /**
 25  
  * Internal class that handles dozer events and invokes any public event listeners. Only intended for internal use.
 26  
  * 
 27  
  * @author garsombke.franz
 28  
  */
 29  
 public final class DozerEventManager implements EventManager {
 30  
   
 31  
   private final List<? extends DozerEventListener> eventListeners;
 32  
 
 33  685
   public DozerEventManager(List<? extends DozerEventListener> eventListeners) {
 34  685
     this.eventListeners = eventListeners;
 35  685
   }
 36  
 
 37  
   public void fireEvent(DozerEvent event) {
 38  
     // If no listeners were specified, then just return.
 39  624100
     if (eventListeners == null) {
 40  0
       return;
 41  
     }
 42  624100
     DozerEventType eventType = event.getType();
 43  624100
     for (DozerEventListener listener : eventListeners) {
 44  1
       switch (eventType) {
 45  
        case MAPPING_STARTED:
 46  1
          listener.mappingStarted(event);
 47  1
          break;
 48  
        case MAPPING_PRE_WRITING_DEST_VALUE:
 49  0
          listener.preWritingDestinationValue(event);
 50  0
          break;
 51  
        case MAPPING_POST_WRITING_DEST_VALUE:
 52  0
          listener.postWritingDestinationValue(event);
 53  0
          break;
 54  
        case MAPPING_FINISHED:
 55  0
          listener.mappingFinished(event);
 56  0
          break;
 57  
        default:
 58  0
          MappingUtils.throwMappingException("Unsupported event type: " + eventType);
 59  
        break;
 60  
       }
 61  1
     }
 62  624100
   }
 63  
 
 64  
 }