Skip to content

Generic Definitions on Static Methods #18

Discussion options

You must be logged in to vote

Hello, Thank you for your feedback! :-)
To solve your problem you need to call FunctionSourceGenerator's setTypeDeclaration method as follow:

FunctionSourceGenerator.create("builder")
.addModifier(Modifier.PUBLIC | Modifier.STATIC)
.setTypeDeclaration(
	TypeDeclarationSourceGenerator.create(
		GenericSourceGenerator.create("X")
	)
)
.setReturnType(
	TypeDeclarationSourceGenerator.create("Builder").addGeneric(GenericSourceGenerator.create("X"))
)

For further examples you can also visit the UnitSourceGeneratorTest class that contains a series of tests that together represent a complete example of what you can do with source generators.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by MorningSage
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #17 on July 07, 2022 10:55.