Coverage Report - de.smartics.exceptions.report.ReportBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
ReportBuilder
0%
0/14
0%
0/2
1,667
 
 1  
 /*
 2  
  * Copyright 2007-2013 smartics, Kronseder & Reiner GmbH
 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 de.smartics.exceptions.report;
 17  
 
 18  
 import java.util.Collection;
 19  
 
 20  
 import javax.annotation.concurrent.NotThreadSafe;
 21  
 
 22  
 import com.thoughtworks.qdox.model.JavaClass;
 23  
 
 24  
 import de.smartics.exceptions.report.data.ExceptionCodesReport;
 25  
 import de.smartics.exceptions.report.data.ReportProblem;
 26  
 import de.smartics.exceptions.report.qdox.ExceptionCodeSearcher;
 27  
 import de.smartics.util.lang.Arg;
 28  
 import de.smartics.util.lang.NullArgumentException;
 29  
 
 30  
 /**
 31  
  * Builder of reports on smartics exception codes.
 32  
  */
 33  
 @NotThreadSafe
 34  
 public final class ReportBuilder extends AbstractBuilder
 35  
 {
 36  
   // ********************************* Fields *********************************
 37  
 
 38  
   // --- constants ------------------------------------------------------------
 39  
 
 40  
   // --- members --------------------------------------------------------------
 41  
 
 42  
   // ****************************** Initializer *******************************
 43  
 
 44  
   // ****************************** Constructors ******************************
 45  
 
 46  
   private ReportBuilder(final ReportConfiguration configuration)
 47  
   {
 48  0
     super(configuration);
 49  0
   }
 50  
 
 51  
   // ****************************** Inner Classes *****************************
 52  
 
 53  
   // ********************************* Methods ********************************
 54  
 
 55  
   // --- init -----------------------------------------------------------------
 56  
 
 57  
   // --- create ---------------------------------------------------------------
 58  
 
 59  
   /**
 60  
    * Factory method to create an instance of a report builder.
 61  
    *
 62  
    * @param configuration the configuration to control the generation of the
 63  
    *          report.
 64  
    * @return the configured report builder.
 65  
    */
 66  
   public static ReportBuilder create(final ReportConfiguration configuration)
 67  
   {
 68  0
     return new ReportBuilder(configuration);
 69  
   }
 70  
 
 71  
   // --- get&set --------------------------------------------------------------
 72  
 
 73  
   // --- business -------------------------------------------------------------
 74  
 
 75  
   /**
 76  
    * Runs the report process and writes to the given report.
 77  
    *
 78  
    * @param report the report to write to.
 79  
    * @throws NullArgumentException if {@code report} is <code>null</code>.
 80  
    */
 81  
   public void reportTo(final ExceptionCodesReport report)
 82  
     throws NullArgumentException
 83  
   {
 84  0
     Arg.checkNotNull("report", report);
 85  
 
 86  0
     notifyOfParseProblems(report);
 87  
 
 88  0
     final ExceptionCodeSearcher searcher = new ExceptionCodeSearcher();
 89  0
     final Collection<JavaClass> exceptionCodeTypes =
 90  
         javaProjectBuilder.search(searcher);
 91  0
     final AddReportItemHelper helper =
 92  
         new AddReportItemHelper(runtimeUtils, report);
 93  0
     for (final JavaClass exceptionCodeType : exceptionCodeTypes)
 94  
     {
 95  
       try
 96  
       {
 97  0
         helper.addReportItems(exceptionCodeType);
 98  
       }
 99  0
       catch (final Exception e)
 100  
       {
 101  0
         report.addProblem(new ReportProblem("Cannot add report item.", e));
 102  0
       }
 103  
     }
 104  0
   }
 105  
 
 106  
   // --- object basics --------------------------------------------------------
 107  
 
 108  
 }