public GenerifiedClass(final JDefinedClass definedClass, final String typeParameterName) { this.raw = definedClass; this.typeParam = definedClass.generify(typeParameterName); this.type = definedClass.narrow(this.typeParam); } }
JMethod generateNewBuilderMethod() { final JMethod builderMethod = this.definedClass.method(JMod.PUBLIC | JMod.STATIC, this.builderClass.raw.narrow(Void.class), this.settings.getNewBuilderMethodName()); builderMethod.body()._return(JExpr._new(this.builderClass.raw.narrow(Void.class)).arg(JExpr._null()).arg(JExpr._null()).arg(JExpr.FALSE)); return builderMethod; }
/** * Javadoc setup. */ @RequiredArgsConstructor private enum JavaDocs { DOCS_TOP_CLASS("top_class"), DOCS_CONSTRUCTOR("constructor"); private static final String JAVADOC_DIR = "arbitrary-action-builder-procreator"; private final String name; String fillTemplate(final Object... params) { return String.format(JavadocUtils.getTemplateString(JAVADOC_DIR, name), params); } }
private JMethod generateConveniencePartialCopyMethod(final TypeOutline paramType, final JMethod partialCopyOfMethod, final String methodName, final JExpression propertyTreeUseArg) { if (paramType.getSuperClass() != null) { generateConveniencePartialCopyMethod(paramType.getSuperClass(), partialCopyOfMethod, methodName, propertyTreeUseArg); } final JMethod conveniencePartialCopyMethod = this.definedClass.method(JMod.PUBLIC | JMod.STATIC, this.builderClass.raw.narrow(Void.class), methodName); final JVar partialOtherParam = conveniencePartialCopyMethod.param(JMod.FINAL, paramType.getImplClass(), BuilderGenerator.OTHER_PARAM_NAME); final JVar propertyPathParam = conveniencePartialCopyMethod.param(JMod.FINAL, PropertyTree.class, PartialCopyGenerator.PROPERTY_TREE_PARAM_NAME); conveniencePartialCopyMethod.body()._return(JExpr.invoke(partialCopyOfMethod).arg(partialOtherParam).arg(propertyPathParam).arg(propertyTreeUseArg)); return conveniencePartialCopyMethod; }
JMethod generateCopyOfMethod(final TypeOutline paramType, final boolean partial) { if (paramType.getSuperClass() != null) { generateCopyOfMethod(paramType.getSuperClass(), partial); } final JMethod copyOfMethod = this.definedClass.method(JMod.PUBLIC | JMod.STATIC, this.builderClass.raw.narrow(Void.class), this.pluginContext.buildCopyMethodName); final JTypeVar copyOfMethodTypeParam = copyOfMethod.generify(BuilderGenerator.PARENT_BUILDER_TYPE_PARAMETER_NAME); copyOfMethod.type(this.builderClass.raw.narrow(copyOfMethodTypeParam)); final JVar otherParam = copyOfMethod.param(JMod.FINAL, paramType.getImplClass(), BuilderGenerator.OTHER_PARAM_NAME); final CopyGenerator copyGenerator = this.pluginContext.createCopyGenerator(copyOfMethod, partial); final JVar newBuilderVar = copyOfMethod.body().decl(JMod.FINAL, copyOfMethod.type(), BuilderGenerator.NEW_BUILDER_VAR_NAME, JExpr._new(copyOfMethod.type()).arg(JExpr._null()).arg(JExpr._null()).arg(JExpr.FALSE)); copyOfMethod.body().add(copyGenerator.generatePartialArgs(this.pluginContext.invoke(otherParam, this.settings.getCopyToMethodName()).arg(newBuilderVar))); copyOfMethod.body()._return(newBuilderVar); return copyOfMethod; }
anyActionBuilderClass._extends(arbitraryActionBuilder.narrow(anyActionBuilderClass)); anyActionBuilderClass._implements(actionSettableInterface.narrow(anyActionBuilderClass)); anyActionBuilderClass._implements(actionWithPayloadInterface.narrow(anyActionBuilderClass).narrow(Object.class));
JMethod generateNewCopyBuilderMethod(final boolean partial) { final JDefinedClass typeDefinition = this.typeOutline.isInterface() && ((DefinedInterfaceOutline)this.typeOutline).getSupportInterface() != null ? ((DefinedInterfaceOutline)this.typeOutline).getSupportInterface() : this.definedClass; final int mods = this.implement ? this.definedClass.isAbstract() ? JMod.PUBLIC | JMod.ABSTRACT : JMod.PUBLIC : JMod.NONE; final JMethod copyBuilderMethod = typeDefinition.method(mods, this.builderClass.raw, this.settings.getNewCopyBuilderMethodName()); final JTypeVar copyBuilderMethodTypeParam = copyBuilderMethod.generify(BuilderGenerator.PARENT_BUILDER_TYPE_PARAMETER_NAME); final JVar parentBuilderParam = copyBuilderMethod.param(JMod.FINAL, copyBuilderMethodTypeParam, BuilderGenerator.PARENT_BUILDER_PARAM_NAME); final CopyGenerator copyGenerator = this.pluginContext.createCopyGenerator(copyBuilderMethod, partial); copyBuilderMethod.type(this.builderClass.raw.narrow(copyBuilderMethodTypeParam)); final JMethod copyBuilderConvenienceMethod = typeDefinition.method(mods, this.builderClass.raw.narrow(this.pluginContext.voidClass), this.settings.getNewCopyBuilderMethodName()); final CopyGenerator copyConvenienceGenerator = this.pluginContext.createCopyGenerator(copyBuilderConvenienceMethod, partial); if (this.implement && !this.definedClass.isAbstract()) { copyBuilderMethod.body()._return(copyGenerator.generatePartialArgs(this.pluginContext._new((JClass)copyBuilderMethod.type()).arg(parentBuilderParam).arg(JExpr._this()).arg(JExpr.TRUE))); copyBuilderConvenienceMethod.body()._return(copyConvenienceGenerator.generatePartialArgs(this.pluginContext.invoke(this.settings.getNewCopyBuilderMethodName()).arg(JExpr._null()))); } if (this.typeOutline.getSuperClass() != null) { copyBuilderMethod.annotate(Override.class); copyBuilderConvenienceMethod.annotate(Override.class); } return copyBuilderMethod; }
builder._extends(arbitraryActionBuilder.narrow(builder));
public void generateMetaFields() { if(this.classOutline.getSuperClass() != null) { this.selectorClass._extends(this.selectorGenerator.getInfoClass(this.classOutline.getSuperClass().implClass).selectorClass.narrow(this.rootTypeParam).narrow(this.parentTypeParam)); final JClass returnType; if (modelClass != null) { returnType = this.selectorGenerator.getInfoClass(modelClass.implClass).selectorClass.narrow(this.rootTypeParam).narrow(this.selectorClass.narrow(this.rootTypeParam).narrow(this.parentTypeParam)); } else { returnType = this.selectorGenerator.getPluginContext().codeModel.ref(this.selectorGenerator.selectorBaseClass).narrow(this.rootTypeParam).narrow(this.selectorClass.narrow(this.rootTypeParam).narrow(this.parentTypeParam));
final void generateCopyToMethod(final boolean partial) { if (this.implement) { final JDefinedClass typeDefinition = this.typeOutline.isInterface() && ((DefinedInterfaceOutline)this.typeOutline).getSupportInterface() != null ? ((DefinedInterfaceOutline)this.typeOutline).getSupportInterface() : this.definedClass; final JMethod copyToMethod = typeDefinition.method(JMod.PUBLIC, this.pluginContext.voidType, this.settings.getCopyToMethodName()); final JTypeVar typeVar = copyToMethod.generify(BuilderGenerator.PARENT_BUILDER_TYPE_PARAMETER_NAME); final JVar otherParam = copyToMethod.param(JMod.FINAL, this.builderClass.raw.narrow(typeVar), BuilderGenerator.OTHER_PARAM_NAME); final CopyGenerator cloneGenerator = this.pluginContext.createCopyGenerator(copyToMethod, partial); final JBlock body = copyToMethod.body(); final JVar otherRef; if (this.typeOutline.getSuperClass() != null) { body.add(cloneGenerator.generatePartialArgs(this.pluginContext.invoke(JExpr._super(), copyToMethod.name()).arg(otherParam))); } otherRef = otherParam; generateFieldCopyExpressions(cloneGenerator, body, otherRef, JExpr._this()); copyToMethod.javadoc().append(getMessage("javadoc.method.copyTo")); copyToMethod.javadoc().addParam(otherParam).append(getMessage("javadoc.method.copyTo.param.other")); } }
rootSelectorClass._extends(selectorClass.narrow(rootSelectorClass).narrow(Void.class)); final JMethod rootSelectorConstructor = rootSelectorClass.constructor(JMod.NONE); if(this.selectorParamName != null) {