@Test public void testZeroInstance() throws Exception { FileDefinition def = new FromInstances().buildFileDefinition( new ArrayList<Instance>( 0 ), new File( "whatever.txt" ), false, false ); Assert.assertEquals( FileDefinition.INSTANCE, def.getFileType()); Assert.assertEquals( 0, def.getBlocks().size()); }
public FileDefinition buildFileDefinition( Collection<Instance> rootInstances, File targetFile, boolean addComment, boolean saveRuntimeInformation ) { FileDefinition result = new FileDefinition( targetFile ); result.setFileType( FileDefinition.INSTANCE ); if( addComment ) { String s = "# File created from an in-memory model,\n# without a binding to existing files."; BlockComment initialComment = new BlockComment( result, s ); result.getBlocks().add( initialComment ); result.getBlocks().add( new BlockBlank( result, "\n" )); } for( Instance rootInstance : rootInstances ) result.getBlocks().addAll( buildInstanceOf( result, rootInstance, addComment, saveRuntimeInformation )); return result; }
FromInstances { public FileDefinition buildFileDefinition( Collection<Instance> rootInstances, File targetFile, boolean addComment, boolean saveRuntimeInformation ) { FileDefinition result = new FileDefinition( targetFile ); result.setFileType( FileDefinition.INSTANCE ); if( addComment ) { String s = "# File created from an in-memory model,\n# without a binding to existing files."; BlockComment initialComment = new BlockComment( result, s ); result.getBlocks().add( initialComment ); result.getBlocks().add( new BlockBlank( result, "\n" )); } for( Instance rootInstance : rootInstances ) result.getBlocks().addAll( buildInstanceOf( result, rootInstance, addComment, saveRuntimeInformation )); return result; } }
FromInstances { public FileDefinition buildFileDefinition( Collection<Instance> rootInstances, File targetFile, boolean addComment, boolean saveRuntimeInformation ) { FileDefinition result = new FileDefinition( targetFile ); result.setFileType( FileDefinition.INSTANCE ); if( addComment ) { String s = "# File created from an in-memory model,\n# without a binding to existing files."; BlockComment initialComment = new BlockComment( result, s ); result.getBlocks().add( initialComment ); result.getBlocks().add( new BlockBlank( result, "\n" )); } for( Instance rootInstance : rootInstances ) result.getBlocks().addAll( buildInstanceOf( result, rootInstance, addComment, saveRuntimeInformation )); return result; }  }
FromInstances { public FileDefinition buildFileDefinition( Collection<Instance> rootInstances, File targetFile, boolean addComment, boolean saveRuntimeInformation ) { FileDefinition result = new FileDefinition( targetFile ); result.setFileType( FileDefinition.INSTANCE ); if( addComment ) { String s = "# File created from an in-memory model,\n# without a binding to existing files."; BlockComment initialComment = new BlockComment( result, s ); result.getBlocks().add( initialComment ); result.getBlocks().add( new BlockBlank( result, "\n" )); } for( Instance rootInstance : rootInstances ) result.getBlocks().addAll( buildInstanceOf( result, rootInstance, addComment, saveRuntimeInformation )); return result; }  FileDefinition buildFileDefinition( Collection<Instance> rootInstances, File targetFile, boolean addComment, boolean saveRuntimeInformation ); }
FromInstances { public FileDefinition buildFileDefinition( Collection<Instance> rootInstances, File targetFile, boolean addComment, boolean saveRuntimeInformation ) { FileDefinition result = new FileDefinition( targetFile ); result.setFileType( FileDefinition.INSTANCE ); if( addComment ) { String s = "# File created from an in-memory model,\n# without a binding to existing files."; BlockComment initialComment = new BlockComment( result, s ); result.getBlocks().add( initialComment ); result.getBlocks().add( new BlockBlank( result, "\n" )); } for( Instance rootInstance : rootInstances ) result.getBlocks().addAll( buildInstanceOf( result, rootInstance, addComment, saveRuntimeInformation )); return result; }  FileDefinition buildFileDefinition( Collection<Instance> rootInstances, File targetFile, boolean addComment, boolean saveRuntimeInformation );  }