Parameters.javaIdentifier("constructorName", constructorName); // NOI18N Parameters.notNull("parameters", parameters); // NOI18N
/** * Creates a new annotation argument whose value is a member of a type. For * example it can be used to generate <code>@Target(ElementType.CONSTRUCTOR)</code>. * * @param argumentName the argument name; cannot be null. * @param argumentType the fully-qualified name of the type whose member is to be invoked * (e.g. <code>java.lang.annotations.ElementType</code> in the previous * example); cannot be null. * @param argumentTypeField a field of <code>argumentType</code> * (e.g. <code>CONSTRUCTOR</code> in the previous example); * cannot be null. * @return the new annotation argument; never null. */ public ExpressionTree createAnnotationArgument(String argumentName, String argumentType, String argumentTypeField) { Parameters.javaIdentifierOrNull("argumentName", argumentName); // NOI18N Parameters.notNull("argumentType", argumentType); // NOI18N Parameters.javaIdentifier("argumentTypeField", argumentTypeField); // NOI18N TreeMaker make = getTreeMaker(); MemberSelectTree argumentValueTree = make.MemberSelect(createQualIdent(argumentType), argumentTypeField); if (argumentName == null) { return argumentValueTree; } else { return make.Assignment(make.Identifier(argumentName), argumentValueTree); } }
/** * Creates a new public property getter method. * * @param modifiersTree the method modifiers; cannot be null. * @param propertyType the property type; cannot be null. * @param propertyName the property name; cannot be null. * @return the new method; never null. */ public MethodTree createPropertyGetterMethod(ModifiersTree modifiersTree, String propertyName, Tree propertyType) { Parameters.notNull("modifiersTree", modifiersTree); // NOI18N Parameters.javaIdentifier("propertyName", propertyName); // NOI18N Parameters.notNull("propertyType", propertyType); // NOI18N return getTreeMaker().Method( modifiersTree, createPropertyAccessorName(propertyName, true), propertyType, Collections.<TypeParameterTree>emptyList(), Collections.<VariableTree>emptyList(), Collections.<ExpressionTree>emptyList(), "{ return " + propertyName + "; }", // NOI18N null); }
/** * Creates a new variable (a <code>VariableTree</code> with no * modifiers nor initializer). * * @param scope the scope in which to create the variable (will be e.g. used * to parse <code>variableType</code>). * @param variableType the fully-qualified name of the variable type; cannot be null. * @param variableName the variable name; cannot be null. * @return the new variable; never null. */ public VariableTree createVariable(TypeElement scope, String variableName, String variableType) { Parameters.javaIdentifier("variableName", variableName); // NOI18N Parameters.notNull("variableType", variableType); // NOI18N return createField( scope, createEmptyModifiers(), variableName, variableType, null); }
/** * Creates a new public property setter method. * * @param modifiersTree the method modifiers; cannot be null. * @param propertyType the property type; cannot be null. * @param propertyName the property name; cannot be null. * @return the new method; never null. */ public MethodTree createPropertySetterMethod(ModifiersTree modifiersTree, String propertyName, Tree propertyType) { Parameters.notNull("modifiersTree", modifiersTree); // NOI18N Parameters.javaIdentifier("propertyName", propertyName); // NOI18N Parameters.notNull("propertyType", propertyType); // NOI18N TreeMaker make = getTreeMaker(); return make.Method( modifiersTree, createPropertyAccessorName(propertyName, false), make.PrimitiveType(TypeKind.VOID), Collections.<TypeParameterTree>emptyList(), Collections.singletonList(createVariable(propertyName, propertyType)), Collections.<ExpressionTree>emptyList(), "{ this." + propertyName + " = " + propertyName + "; }", // NOI18N null); }
/** * Creates a new public property setter method. * * @param scope the scope in which to create the method (will be e.g. used * to parse <code>propertyType</code>). * @param modifiersTree the method modifiers; cannot be null. * @param propertyName the property name; cannot be null. * @param propertyType the fully-qualified name of the property type; cannot be null. * @return the new method; never null. */ public MethodTree createPropertySetterMethod(TypeElement scope, ModifiersTree modifiersTree, String propertyName, String propertyType) { Parameters.notNull("modifiersTree", modifiersTree); // NOI18N Parameters.javaIdentifier("propertyName", propertyName); // NOI18N Parameters.notNull("propertyType", propertyType); // NOI18N return createPropertySetterMethod(modifiersTree, propertyName, createType(propertyType, scope)); }
/** * Creates a new public property getter method. * * @param scope the scope in which to create the method (will be e.g. used * to parse <code>propertyType</code>). * @param modifiersTree the method modifiers; cannot be null. * @param propertyType the fully-qualified name of the property type; cannot be null. * @param propertyName the property name; cannot be null. * @return the new method; never null. */ public MethodTree createPropertyGetterMethod(TypeElement scope, ModifiersTree modifiersTree, String propertyName, String propertyType) { Parameters.notNull("modifiersTree", modifiersTree); // NOI18N Parameters.javaIdentifier("propertyName", propertyName); // NOI18N Parameters.notNull("propertyType", propertyType); // NOI18N return createPropertyGetterMethod(modifiersTree, propertyName, createType(propertyType, scope)); }
/** * Creates a new variable (a <code>VariableTree</code> with no * modifiers nor initializer). * * @param variableType the variable type; cannot be null. * @param variableName the variable name; cannot be null. * @return the new variable; never null. */ public VariableTree createVariable(String variableName, Tree variableType) { Parameters.javaIdentifier("variableName", variableName); // NOI18N Parameters.notNull("variableType", variableType); // NOI18N return getTreeMaker().Variable( createEmptyModifiers(), variableName, variableType, null); }
/** * Creates a new field. * * @param scope the scope in which to create the field (will be e.g. used * to parse <code>fieldType</code>). * @param modifiersTree the field modifiers; cannot be null. * @param fieldType the fully-qualified name of the field type; cannot be null. * @param fieldName the field name; cannot be null. * @param expressionTree expression to initialize the field; can be null. * @return the new field; never null. */ public VariableTree createField(TypeElement scope, ModifiersTree modifiersTree, String fieldName, String fieldType, ExpressionTree expressionTree) { Parameters.notNull("modifiersTree", modifiersTree); // NOI18N Parameters.javaIdentifier("fieldName", fieldName); // NOI18N Parameters.notNull("fieldType", fieldType); // NOI18N return getTreeMaker().Variable( modifiersTree, fieldName, createType(fieldType, scope), expressionTree); }
Parameters.notNull("template", template); // NOI18N Parameters.notNull("targetFolder", targetFolder); // NOI18N Parameters.javaIdentifier("className", className); // NOI18N