Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  
  package com.google.code.joto;
  
  import static com.google.code.joto.ReverseEngineerData.concat;
  
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 

Author(s):
Liliana.nu
epere4
 
 public class ReverseEngineerObject
 {
 
     public ReverseEngineerObjectResponse generateCodeObject objectToProcess,
                                                        List<? extends CustomProcessorlistOfUserSuppliedProcessors )
     {
         List<CustomProcessorlistOfProcessors = makeListOfDefaultProcessors();
         if ( listOfUserSuppliedProcessors != null )
         {
             listOfProcessors.addAll( 0, listOfUserSuppliedProcessors );
         }
 
         ReverseEngineerData sharedData = new ReverseEngineerDatalistOfProcessors );
 
         addSomeClassesToImportAlwayssharedData );
 
         ReverseEngineerData.writeCreatorHeadersharedDataobjectToProcess );
         sharedData.concat"final InstancesMap instancesMap = new InstancesMap();\n" );
         sharedData.concat( ReverseEngineerHelper.getTypeAsStringobjectToProcess ) );
         sharedData.concat" generatedObject = " );
 
         generateCodeRecursivelyobjectToProcesssharedData, 0 );
 
         sharedData.concat";\n" );
         ReverseEngineerData.writeReturnStatementsharedData"generatedObject" );
         ReverseEngineerData.writeCreatorFootersharedData );
 
         String imports = makeImportssharedData.getClassesToImport() );
         String code = sharedData.sb.toString();
 
         return new ReverseEngineerObjectResponseimportscode );
 
     }
 
     private void addSomeClassesToImportAlwaysReverseEngineerData sharedData )
     {
         sharedData.addClassToImportList.class );
         sharedData.addClassToImportSet.class );
         sharedData.addClassToImportMap.class );
         sharedData.addClassToImportCreator.class );
         sharedData.addClassToImportCollection.class );
         sharedData.addClassToImportInstancesMap.class );
     }
 
     {
         LinkedList<CustomProcessorlistOfDefaultProcessors = new LinkedList<CustomProcessor>();
         listOfDefaultProcessors.addnew NullProcessor() );
         listOfDefaultProcessors.addnew PrimitiveTypeProcessor() );
         listOfDefaultProcessors.addnew BooleanProcessor() );
         listOfDefaultProcessors.addnew CharacterProcessor() );
         listOfDefaultProcessors.addnew NumberProcessor() );
         listOfDefaultProcessors.addnew DateProcessor() );
         listOfDefaultProcessors.addnew StringProcessor() );
         listOfDefaultProcessors.addnew CollectionProcessor() );
         listOfDefaultProcessors.addnew MapProcessor() );
         listOfDefaultProcessors.addnew ArrayProcessor() );
         listOfDefaultProcessors.addnew EnumProcessor() );
         listOfDefaultProcessors.addnew MultitonProcessor() );
         listOfDefaultProcessors.addnew DefaultObjectProcessor() );
         return listOfDefaultProcessors;
     }
 
     private void generateCodeRecursivelyObject objectToProcessReverseEngineerData sharedDataint depthLevel )
     {
        try
        {
            if ( objectToProcess != null )
            {
                sharedData.addClassToImportobjectToProcess.getClass() );
            }
            for ( CustomProcessor customProc : sharedData.listOfProcessors )
            {
                if ( customProc.canProcessThisobjectToProcess ) )
                {
                    customProc.processThisobjectToProcesssharedDatadepthLevel,
                                            new ProcessMoreCallbackImplsharedDatadepthLevel + 1 ) );
                    break;
                }
            }
        }
        catch ( Exception e )
        {
            throw new RuntimeExceptione );
        }
    }
    public static String makeImportsSet<ClassclassesToImport )
    {
        StringBuilder sb = new StringBuilder();
        for ( Class clazz : classesToImport )
        {
            if ( !clazz.isArray() && !clazz.isAnonymousClass() && !clazz.isLocalClass() && !clazz.isMemberClass() )
            {
                concatsb"import "clazz.getName(), ";\n" );
            }
        }
        concatsb"import static "ReverseEngineerReflectionUtil.class.getName(), ".*;\n" );
        return sb.toString();
    }
        implements ProcessMoreCallback
    {
        public ProcessMoreCallbackImplReverseEngineerData sharedDataint depthLevel )
        {
            this. = sharedData;
            this. = depthLevel;
        }
        final ReverseEngineerData sharedData;
        final int depthLevel;
        public void processThisObject object )
        {
            ReverseEngineerObject.this.generateCodeRecursivelyobject + 1 );
        }
    }
New to GrepCode? Check out our FAQ X