List<Statement> statements = Lists.create();
statements.add(new TypeBuilder(f, context.resolve(ParquetFormatConfiguration.class))
.newObject()
.toLocalVariableDeclaration(context.resolve(ParquetFormatConfiguration.class), result));
ParquetFormatConfiguration conf = model.getTrait(ParquetFileTrait.class).configuration();
if (conf.getFieldMappingStrategy() != null) {
statements.add(new ExpressionBuilder(f, result)
.method("withFieldMappingStrategy", //$NON-NLS-1$
new TypeBuilder(f, context.resolve(FieldMappingStrategy.class))
.field(conf.getFieldMappingStrategy().name())
.toExpression())
.toStatement());
}
if (conf.getOnMissingSource() != null) {
statements.add(new ExpressionBuilder(f, result)
.method("withOnMissingSource", //$NON-NLS-1$
new TypeBuilder(f, context.resolve(ExceptionHandlingStrategy.class))
.field(conf.getOnMissingSource().name())
.toExpression())
.toStatement());
}
if (conf.getOnMissingTarget() != null) {
statements.add(new ExpressionBuilder(f, result)
.method("withOnMissingTarget", //$NON-NLS-1$
new TypeBuilder(f, context.resolve(ExceptionHandlingStrategy.class))
.field(conf.getOnMissingTarget().name())
.toExpression())
.toStatement());
}
if (conf.getOnIncompatibleType() != null) {
statements.add(new ExpressionBuilder(f, result)
.method("withOnIncompatibleType", //$NON-NLS-1$
new TypeBuilder(f, context.resolve(ExceptionHandlingStrategy.class))
.field(conf.getOnIncompatibleType().name())
.toExpression())
.toStatement());
}
if (conf.getCompressionCodecName() != null) {
statements.add(new ExpressionBuilder(f, result)
.method("withCompressionCodecName", //$NON-NLS-1$
new TypeBuilder(f, context.resolve(CompressionCodecName.class))
.field(conf.getCompressionCodecName().name())
.toExpression())
.toStatement());
}
if (conf.getBlockSize() != null) {
statements.add(new ExpressionBuilder(f, result)
.method("withBlockSize", Models.toLiteral(f, conf.getBlockSize())) //$NON-NLS-1$
.toStatement());
}
if (conf.getDataPageSize() != null) {
statements.add(new ExpressionBuilder(f, result)
.method("withDataPageSize", Models.toLiteral(f, conf.getDataPageSize())) //$NON-NLS-1$
.toStatement());
}
if (conf.getDictionaryPageSize() != null) {
statements.add(new ExpressionBuilder(f, result)
.method("withDictionaryPageSize", Models.toLiteral(f, conf.getDictionaryPageSize())) //$NON-NLS-1$
.toStatement());
}
if (conf.getEnableDictionary() != null) {
statements.add(new ExpressionBuilder(f, result)
.method("withEnableDictionary", Models.toLiteral(f, conf.getEnableDictionary())) //$NON-NLS-1$
.toStatement());
}
if (conf.getEnableValidation() != null) {
statements.add(new ExpressionBuilder(f, result)
.method("withEnableValidation", Models.toLiteral(f, conf.getEnableValidation())) //$NON-NLS-1$
.toStatement());
}
if (conf.getWriterVersion() != null) {
statements.add(new ExpressionBuilder(f, result)
.method("withWriterVersion", //$NON-NLS-1$
new TypeBuilder(f, context.resolve(WriterVersion.class))
.field(conf.getWriterVersion().name())
.toExpression())
.toStatement());
}
statements.add(new ExpressionBuilder(f, result).toReturnStatement());
return f.newMethodDeclaration(