Coverage Report - org.apache.maven.monitor.event.AbstractSelectiveEventMonitor
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractSelectiveEventMonitor
0 %
0/17
0 %
0/6
1,429
 
 1  
 package org.apache.maven.monitor.event;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *  http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.util.Arrays;
 23  
 import java.util.List;
 24  
 
 25  
 /**
 26  
  * @author jdcasey
 27  
  */
 28  
 public abstract class AbstractSelectiveEventMonitor
 29  
     implements EventMonitor
 30  
 {
 31  
     
 32  
     private List boundStartEvents;
 33  
     private List boundErrorEvents;
 34  
     private List boundEndEvents;
 35  
 
 36  
     protected AbstractSelectiveEventMonitor(String[] startEvents, String[] endEvents, String[] errorEvents)
 37  0
     {
 38  0
         this.boundStartEvents = Arrays.asList( startEvents );
 39  
         
 40  0
         this.boundEndEvents = Arrays.asList( endEvents );
 41  
         
 42  0
         this.boundErrorEvents = Arrays.asList( errorEvents );
 43  0
     }
 44  
 
 45  
     public final void startEvent( String eventName, String target, long timestamp )
 46  
     {
 47  0
         if( boundStartEvents.contains( eventName ) )
 48  
         {
 49  0
             doStartEvent( eventName, target, timestamp );
 50  
         }
 51  0
     }
 52  
     
 53  
     protected void doStartEvent( String eventName, String target, long timestamp )
 54  
     {
 55  0
     }
 56  
 
 57  
     public final void endEvent( String eventName, String target, long timestamp )
 58  
     {
 59  0
         if( boundEndEvents.contains( eventName ) )
 60  
         {
 61  0
             doEndEvent( eventName, target, timestamp );
 62  
         }
 63  0
     }
 64  
 
 65  
     protected void doEndEvent( String eventName, String target, long timestamp )
 66  
     {
 67  0
     }
 68  
 
 69  
     public final void errorEvent( String eventName, String target, long timestamp, Throwable cause )
 70  
     {
 71  0
         if( boundErrorEvents.contains( eventName ) )
 72  
         {
 73  0
             doErrorEvent( eventName, target, timestamp, cause );
 74  
         }
 75  0
     }
 76  
 
 77  
     protected void doErrorEvent( String eventName, String target, long timestamp, Throwable cause )
 78  
     {
 79  0
     }
 80  
 
 81  
 }