Coverage Report - org.org.usurper.utils.UsurperGeneratorSetupUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
UsurperGeneratorSetupUtils
0 %
0/25
0 %
0/8
0
 
 1  
 /*
 2  
  ORG Usurper is a random value object generator library 
 3  
  Copyright (C) 2007  Pierre-Antoine GrĂ©goire
 4  
  
 5  
  This library is free software; you can redistribute it and/or
 6  
  modify it under the terms of the GNU Lesser General Public
 7  
  License as published by the Free Software Foundation; either
 8  
  version 2.1 of the License, or (at your option) any later version.
 9  
  
 10  
  This library is distributed in the hope that it will be useful,
 11  
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
  Lesser General Public License for more details.
 14  
  
 15  
  You should have received a copy of the GNU Lesser General Public
 16  
  License along with this library; if not, write to the Free Software
 17  
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 18  
  */
 19  
 package org.org.usurper.utils;
 20  
 
 21  
 import java.util.SortedSet;
 22  
 import java.util.TreeSet;
 23  
 
 24  
 import org.org.usurper.handlers.basic.AbstractSpecificPropertyHandler;
 25  
 import org.org.usurper.model.PropertyTypeDefinition;
 26  
 import org.org.usurper.setup.IUsurperGeneratorSetup;
 27  
 /**
 28  
  * This class is an UsurperGeneratorSetup utility class
 29  
  * 
 30  
  * @author pagregoire
 31  
  */
 32  
 public final class UsurperGeneratorSetupUtils {
 33  
 
 34  0
     private UsurperGeneratorSetupUtils() {
 35  0
     }
 36  
 
 37  
     /**
 38  
      * This method builds a String representation of an IUsurperGeneratorSetup instance.
 39  
      * 
 40  
      * @param usurperGeneratorSetup the usurper generator setup
 41  
      * 
 42  
      * @return the string
 43  
      */
 44  
     public static String buildStringRepresentation(IUsurperGeneratorSetup usurperGeneratorSetup) {
 45  0
         StringBuilder stringBuilder = new StringBuilder();
 46  0
         stringBuilder.append("--------------------------------------------\n");
 47  0
         stringBuilder.append("Usurper Generator setup:" + usurperGeneratorSetup.getClass().getName() + "\n");
 48  0
         stringBuilder.append("---------\n");
 49  0
         stringBuilder.append("Array handler: " + usurperGeneratorSetup.getArrayHandler().getClass().getName() + "\n");
 50  0
         stringBuilder.append("Enum handler: " + usurperGeneratorSetup.getEnumHandler().getClass().getName() + "\n");
 51  0
         stringBuilder.append("Count callback: " + usurperGeneratorSetup.getCountCallback().getClass().getName() + "\n");
 52  0
         stringBuilder.append("On missing handlers: " + usurperGeneratorSetup.getOnMissingHandlers().toString() + "\n");
 53  0
         stringBuilder.append("Property writing mechanism: " + usurperGeneratorSetup.getPropertyWritingMechanism().toString() + "\n");
 54  0
         stringBuilder.append("---------\n");
 55  0
         SortedSet<String> sortedSet = new TreeSet<String>();
 56  0
         for (PropertyTypeDefinition handledProperty : usurperGeneratorSetup.getPropertyTypeHandlersMap().keySet()) {
 57  0
             sortedSet.add(handledProperty + ": " + usurperGeneratorSetup.getPropertyTypeHandlersMap().get(handledProperty).getClass().getName() + "\n");
 58  
         }
 59  0
         for (String message : sortedSet) {
 60  0
             stringBuilder.append(message);
 61  
         }
 62  0
         stringBuilder.append("---------\n");
 63  0
         sortedSet = new TreeSet<String>();
 64  0
         for (AbstractSpecificPropertyHandler abstractSpecificPropertyHandler : usurperGeneratorSetup.getSpecificPropertyHandlersMap().values()) {
 65  0
             sortedSet.add(abstractSpecificPropertyHandler.getTargetProperty().getPropertyPathString() + ": " + abstractSpecificPropertyHandler.getClass().getName() + "\n");
 66  
         }
 67  0
         for (String message : sortedSet) {
 68  0
             stringBuilder.append(message);
 69  
         }
 70  0
         stringBuilder.append("--------------------------------------------\n");
 71  0
         return stringBuilder.toString();
 72  
     }
 73  
 
 74  
 }