Skip to content

Commit

Permalink
use parameters from addJavaAnnotation (#144)
Browse files Browse the repository at this point in the history
* use parameters from addJavaAnnotation

* fix parameters
  • Loading branch information
mshima authored Jun 7, 2024
1 parent dd6e33c commit 2d5ddfc
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions generators/server/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,11 @@ export default class extends ServerGenerator {
const { mainClass, javaPackageSrcDir, packageName } = application;

this.editFile(`${javaPackageSrcDir}${mainClass}.java`, { assertModified: true }, contents =>
addJavaAnnotation(contents, { package: 'org.springframework.context.annotation', annotation: 'ImportRuntimeHints' }).replaceAll(
'@ImportRuntimeHints\n',
`@ImportRuntimeHints({ ${packageName}.config.NativeConfiguration.JHipsterNativeRuntimeHints.class })\n`,
),
addJavaAnnotation(contents, {
package: 'org.springframework.context.annotation',
annotation: 'ImportRuntimeHints',
parameters: () => `{ ${packageName}.config.NativeConfiguration.JHipsterNativeRuntimeHints.class }`,
}),
);

if (application.databaseMigrationLiquibase) {
Expand Down Expand Up @@ -286,7 +287,8 @@ import org.springframework.security.oauth2.core.oidc.user.OidcUser;`,
addJavaAnnotation(contents, {
package: 'org.springframework.aot.hint.annotation',
annotation: 'RegisterReflectionForBinding',
}).replace('@RegisterReflectionForBinding\n', '@RegisterReflectionForBinding({ FieldErrorVM.class })\n'),
parameters: () => '{ FieldErrorVM.class }',
}),
);
},

Expand Down Expand Up @@ -333,10 +335,11 @@ import org.springframework.security.oauth2.core.oidc.user.OidcUser;`,
for (const entity of entities.filter(({ builtIn, builtInUser, embedded }) => builtInUser || (!builtIn && !embedded))) {
const entityClassFilePath = `${application.srcMainJava}/${entity.entityAbsoluteFolder}/domain/${entity.entityClass}.java`;
this.editFile(entityClassFilePath, { assertModified: true }, content =>
addJavaAnnotation(content, { package: 'com.fasterxml.jackson.annotation', annotation: 'JsonFilter' }).replace(
'@JsonFilter\n',
'@JsonFilter("lazyPropertyFilter")\n',
),
addJavaAnnotation(content, {
package: 'com.fasterxml.jackson.annotation',
annotation: 'JsonFilter',
parameters: () => '"lazyPropertyFilter"',
}),
);
}
},
Expand Down

0 comments on commit 2d5ddfc

Please sign in to comment.