Skip to content

Commit

Permalink
chore: fix sonar warning
Browse files Browse the repository at this point in the history
  • Loading branch information
princerajpoot20 committed Oct 3, 2023
1 parent 9c5f0e6 commit f72e50c
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/generators/java/JavaConstrainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,15 @@ export const JavaDefaultTypeMapping: JavaTypeMapping = {
},
Float({ constrainedModel }): string {
let type = 'Double';
const format =
constrainedModel.originalInput &&
constrainedModel.originalInput['format'];
switch (format) {
case 'float':
type = 'float';
break;
const format = constrainedModel.originalInput?.['format'];
if (format === 'float') {
type = 'float';
}
return type;
},
Integer({ constrainedModel }): string {
let type = 'Integer';
const format =
constrainedModel.originalInput &&
constrainedModel.originalInput['format'];
const format = constrainedModel.originalInput?.['format'];
switch (format) {
case 'integer':
case 'int32':
Expand All @@ -113,9 +107,7 @@ export const JavaDefaultTypeMapping: JavaTypeMapping = {
},
String({ constrainedModel }): string {
let type = 'String';
const format =
constrainedModel.originalInput &&
constrainedModel.originalInput['format'];
const format = constrainedModel.originalInput?.['format'];
switch (format) {
case 'date':
type = 'java.time.LocalDate';
Expand Down Expand Up @@ -151,9 +143,7 @@ export const JavaDefaultTypeMapping: JavaTypeMapping = {
return `${constrainedModel.valueModel.type}[]`;
},
Enum({ constrainedModel }): string {
const format =
constrainedModel.originalInput &&
constrainedModel.originalInput['format'];
const format = constrainedModel.originalInput?.['format'];
const valueTypes = constrainedModel.values.map((enumValue) =>
fromEnumValueToType(enumValue, format)
);
Expand Down

0 comments on commit f72e50c

Please sign in to comment.