Skip to content

Commit

Permalink
Merge pull request #25286 from mshima/properties
Browse files Browse the repository at this point in the history
add addApplicationPropertiesProperty needle
  • Loading branch information
DanielFran committed Feb 21, 2024
2 parents b8c0fd3 + 328eaf4 commit 108fdf0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions generators/server/types.d.ts
Expand Up @@ -30,6 +30,7 @@ export type SpringBootSourceType = GradleSourceType &
addIntegrationTestAnnotation?({ package, annotation }: { package?: string; annotation: string }): void;
addAllowBlockingCallsInside?({ classPath, method }: { classPath: string; method: string }): void;
addApplicationPropertiesContent?(content: ApplicationPropertiesNeedles): void;
addApplicationPropertiesProperty?({ propertyName, propertyType }: { propertyName: string; propertyType: string }): void;
};

type CacheProviderApplication = OptionWithDerivedProperties<
Expand Down
14 changes: 14 additions & 0 deletions generators/spring-boot/generator.ts
Expand Up @@ -41,6 +41,7 @@ import {
getPrimaryKeyValue,
getSpecificationBuildForType,
insertContentIntoApplicationProperties,
javaBeanCase,
} from '../server/support/index.js';
import { addJavaAnnotation, generateKeyStore } from '../java/support/index.js';
import { createNeedleCallback, mutateData } from '../base/support/index.js';
Expand Down Expand Up @@ -216,6 +217,19 @@ export default class SpringBootGenerator extends BaseApplicationGenerator {
`${application.javaPackageSrcDir}config/ApplicationProperties.java`,
insertContentIntoApplicationProperties(needles),
);
source.addApplicationPropertiesProperty = ({ propertyName, propertyType }) =>
source.addApplicationPropertiesContent!({
property: `private ${propertyType} ${propertyName};`,
propertyGetter: `
public ${propertyType} get${javaBeanCase(propertyName)}() {
return ${propertyName};
}
public void set${javaBeanCase(propertyName)}(${propertyType} ${propertyName}) {
this.${propertyName} = ${propertyName};
}
`,
});
},
});
}
Expand Down

0 comments on commit 108fdf0

Please sign in to comment.