private ExpressionStatement mapField(SimpleName name) { return new ExpressionBuilder(f, f.newThis()) .field(name) .assignFrom(name) .toStatement(); }
private ExpressionStatement mapField(SimpleName name) { return new ExpressionBuilder(f, f.newThis()) .field(name) .assignFrom(name) .toStatement(); }
private ExpressionStatement mapField(SimpleName name) { return new ExpressionBuilder(f, f.newThis()) .field(name) .assignFrom(name) .toStatement(); }
private ExpressionStatement mapField(SimpleName name) { return new ExpressionBuilder(f, f.newThis()) .field(name) .assignFrom(name) .toStatement(); }
private ExpressionStatement mapField(SimpleName name) { return new ExpressionBuilder(f, f.newThis()) .field(name) .assignFrom(name) .toStatement(); }
private ExpressionStatement mapField(SimpleName name) { return new ExpressionBuilder(f, f.newThis()) .field(name) .assignFrom(name) .toStatement(); }
private MethodDeclaration createReferenceGetter(PropertyReferenceDeclaration reference) throws IOException { List<Attribute> attributes = new ArrayList<>(); attributes.addAll(driver.getMemberAnnotations(context, reference)); attributes.addAll(new AttributeBuilder(f) .Public() .toAttributes()); return f.newMethodDeclaration( new JavadocBuilder(f) .text(Messages.getString("ConcreteModelEmitter.javadocReferenceGetter"), //$NON-NLS-1$ context.getDescription(reference)) .returns() .text(context.getDescription(reference)) .toJavadoc(), attributes, context.getContainerType(reference), context.getReferenceGetterName(reference), Collections.emptyList(), Arrays.asList(new ExpressionBuilder(f, f.newThis()) .field(context.getFieldName(reference)) .toReturnStatement())); } }
private MethodDeclaration createOptionGetter(PropertyDeclaration property) throws IOException { assert property != null; List<Attribute> attributes = new ArrayList<>(); attributes.addAll(driver.getMemberAnnotations(context, property)); attributes.addAll(new AttributeBuilder(f) .Public() .toAttributes()); return f.newMethodDeclaration( new JavadocBuilder(f) .text(Messages.getString("ConcreteModelEmitter.javadocOptionGetter"), //$NON-NLS-1$ context.getDescription(property)) .returns() .text(context.getDescription(property)) .toJavadoc(), attributes, context.getFieldType(property), context.getOptionGetterName(property), Collections.emptyList(), Collections.singletonList(new ExpressionBuilder(f, f.newThis()) .field(context.getFieldName(property)) .toReturnStatement())); }
private MethodDeclaration createResetMethod() { List<Statement> statements = new ArrayList<>(); for (PropertyDeclaration property : model.getDeclaredProperties()) { statements.add(new ExpressionBuilder(f, f.newThis()) .field(context.getFieldName(property)) .method("setNull") //$NON-NLS-1$ .toStatement()); } return f.newMethodDeclaration( null, new AttributeBuilder(f) .annotation(context.resolve(Override.class)) .annotation(context.resolve(SuppressWarnings.class), Models.toLiteral(f, "deprecation")) //$NON-NLS-1$ .Public() .toAttributes(), context.resolve(void.class), f.newSimpleName("reset"), //$NON-NLS-1$ Collections.emptyList(), statements); }
private MethodDeclaration createValueGetter(PropertyDeclaration property) { assert property != null; List<Attribute> attributes = new ArrayList<>(); attributes.addAll(new AttributeBuilder(f) .Public() .toAttributes()); return f.newMethodDeclaration( new JavadocBuilder(f) .text(Messages.getString("ConcreteModelEmitter.javadocGetter"), //$NON-NLS-1$ context.getDescription(property)) .returns() .text(context.getDescription(property)) .exception(context.resolve(NullPointerException.class)) .text(Messages.getString( "ConcreteModelEmitter.javadocGetterNullPointerException"), //$NON-NLS-1$ context.getDescription(property)) .toJavadoc(), attributes, context.getValueType(property), context.getValueGetterName(property), Collections.emptyList(), Collections.singletonList(new ExpressionBuilder(f, f.newThis()) .field(context.getFieldName(property)) .method("get") //$NON-NLS-1$ .toReturnStatement())); }
statements.add(createNullCheck(columnNames)); SimpleName vector = f.newSimpleName("vector"); //$NON-NLS-1$ statements.add(new ExpressionBuilder(f, f.newThis()) .method(NAME_CREATE_VECTOR, columnNames) .toLocalVariableDeclaration(context.resolve(int[].class), vector));
statements.add(createNullCheck(columnNames)); SimpleName vector = f.newSimpleName("vector"); //$NON-NLS-1$ statements.add(new ExpressionBuilder(f, f.newThis()) .method(NAME_CREATE_VECTOR, columnNames) .toLocalVariableDeclaration(context.resolve(int[].class), vector));
private MethodDeclaration createCopyMethod() { SimpleName other = context.createVariableName("other"); //$NON-NLS-1$ List<Statement> statements = new ArrayList<>(); for (PropertyDeclaration property : model.getDeclaredProperties()) { statements.add(new ExpressionBuilder(f, f.newThis()) .field(context.getFieldName(property)) .method("copyFrom", new ExpressionBuilder(f, other) //$NON-NLS-1$ .field(context.getFieldName(property)) .toExpression()) .toStatement()); } return f.newMethodDeclaration( null, new AttributeBuilder(f) .annotation(context.resolve(Override.class)) .annotation(context.resolve(SuppressWarnings.class), Models.toLiteral(f, "deprecation")) //$NON-NLS-1$ .Public() .toAttributes(), context.resolve(void.class), f.newSimpleName("copyFrom"), //$NON-NLS-1$ Collections.singletonList(f.newFormalParameterDeclaration( context.resolve(context.getQualifiedTypeName()), other)), statements); }
statements.add(f.newTryStatement( f.newBlock( new ExpressionBuilder(f, f.newThis()) .method(NAME_CREATE_VECTOR, columnNames) .toStatement(),
private Expression createCompressionCodec() { String codecName = CodecNames.resolveCodecName(conf.getCodecName()); if (codecName == null) { return null; } assert isHadoopConfRequired(); return new TypeBuilder(f, context.resolve(Models.toName(f, "org.apache.hadoop.util.ReflectionUtils"))) //$NON-NLS-1$ .method("newInstance", //$NON-NLS-1$ new TypeBuilder(f, context.resolve(Models.toName(f, codecName))) .dotClass() .toExpression(), new ExpressionBuilder(f, f.newThis()) .method("getConf") //$NON-NLS-1$ .toExpression()) .toExpression(); }
private Expression createCompressionCodec() { String codecName = CodecNames.resolveCodecName(conf.getCodecName()); if (codecName == null) { return null; } assert isHadoopConfRequired(); return new TypeBuilder(f, context.resolve(Models.toName(f, "org.apache.hadoop.util.ReflectionUtils"))) //$NON-NLS-1$ .method("newInstance", //$NON-NLS-1$ new TypeBuilder(f, context.resolve(Models.toName(f, codecName))) .dotClass() .toExpression(), new ExpressionBuilder(f, f.newThis()) .method("getConf") //$NON-NLS-1$ .toExpression()) .toExpression(); }
private Expression createCompressionCodec() { String codecName = CodecNames.resolveCodecName(conf.getCodecName()); if (codecName == null) { return null; } assert isHadoopConfRequired(); return new TypeBuilder(f, context.resolve(Models.toName(f, "org.apache.hadoop.util.ReflectionUtils"))) //$NON-NLS-1$ .method("newInstance", //$NON-NLS-1$ new TypeBuilder(f, context.resolve(Models.toName(f, codecName))) .dotClass() .toExpression(), new ExpressionBuilder(f, f.newThis()) .method("getConf") //$NON-NLS-1$ .toExpression()) .toExpression(); }
private MethodDeclaration createValueSetter(PropertyDeclaration property) { assert property != null; SimpleName paramName = context.createVariableName("value"); //$NON-NLS-1$ Type valueType = context.getValueType(property); return f.newMethodDeclaration( new JavadocBuilder(f) .text(Messages.getString("ConcreteModelEmitter.javadocSetter"), //$NON-NLS-1$ context.getDescription(property)) .param(paramName) .text(Messages.getString("ConcreteModelEmitter.javadocSetterParameter"), //$NON-NLS-1$ context.getDescription(property)) .toJavadoc(), new AttributeBuilder(f) .annotation( context.resolve(SuppressWarnings.class), Models.toLiteral(f, "deprecation")) //$NON-NLS-1$ .Public() .toAttributes(), context.resolve(void.class), context.getValueSetterName(property), Arrays.asList(new FormalParameterDeclaration[] { f.newFormalParameterDeclaration(valueType, paramName) }), Collections.singletonList(new ExpressionBuilder(f, f.newThis()) .field(context.getFieldName(property)) .method("modify", paramName) //$NON-NLS-1$ .toStatement())); }
private MethodDeclaration createOptionSetter(PropertyDeclaration property) { assert property != null; SimpleName paramName = context.createVariableName("option"); //$NON-NLS-1$ Type optionType = context.getFieldType(property); return f.newMethodDeclaration( new JavadocBuilder(f) .text(Messages.getString("ConcreteModelEmitter.javadocOptionSetter"), //$NON-NLS-1$ context.getDescription(property)) .param(paramName) .text(Messages.getString("ConcreteModelEmitter.javadocOptionSetterParameter"), //$NON-NLS-1$ context.getDescription(property)) .toJavadoc(), new AttributeBuilder(f) .annotation( context.resolve(SuppressWarnings.class), Models.toLiteral(f, "deprecation")) //$NON-NLS-1$ .Public() .toAttributes(), context.resolve(void.class), context.getOptionSetterName(property), Arrays.asList(new FormalParameterDeclaration[] { f.newFormalParameterDeclaration(optionType, paramName) }), Collections.singletonList(new ExpressionBuilder(f, f.newThis()) .field(context.getFieldName(property)) .method("copyFrom", paramName) //$NON-NLS-1$ .toStatement())); }
private MethodDeclaration createStringGetter(EmitContext context, PropertyDeclaration property) { assert context != null; assert property != null; JavaName name = JavaName.of(property.getName()); name.addFirst("get"); //$NON-NLS-1$ name.addLast("as"); //$NON-NLS-1$ name.addLast("string"); //$NON-NLS-1$ ModelFactory f = context.getModelFactory(); return f.newMethodDeclaration( new JavadocBuilder(f) .text(Messages.getString("StringPropertyDriver.javadocGetter"), //$NON-NLS-1$ context.getDescription(property)) .returns() .text(context.getDescription(property)) .exception(context.resolve(NullPointerException.class)) .text(Messages.getString("StringPropertyDriver.javadocGetterNullPointerException"), //$NON-NLS-1$ context.getDescription(property)) .toJavadoc(), new AttributeBuilder(f) .Public() .toAttributes(), context.resolve(String.class), f.newSimpleName(name.toMemberName()), Collections.emptyList(), Collections.singletonList(new ExpressionBuilder(f, f.newThis()) .field(context.getFieldName(property)) .method("getAsString") //$NON-NLS-1$ .toReturnStatement())); }