Skip to content

Commit

Permalink
fixed code format
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsontom committed Nov 21, 2024
1 parent 654ee21 commit ba28baa
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions dsl/src/cli/java-server-jakarta-ws/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,39 @@ export function generateRecordContent(t: MResolvedRecordType, artifactConfig: Ja
})

node.appendNewLine();
node.append(`public static ${t.name}DTOImpl of(${artifactConfig.rootPackageName}.service.dto.${t.name}DTO source) {`,NL)
node.indent( body => {
body.append(`if(source instanceof ${t.name}DTOImpl) {`,NL)
body.indent(inner => {
inner.append(`return (${t.name}DTOImpl)source;`,NL)
})
body.append('}')
body.appendNewLine();
body.append(`return new ${t.name}DTOImpl(`,NL);
body.indent( inner => {
allProps.forEach( (p, idx, arr) => {
if( isMKeyProperty(p) || isMRevisionProperty(p) || (p.variant !== 'union' && p.variant !== 'record') ) {
inner.append(`source.${p.name}()`)
} else {
if( p.array ) {
inner.append(`source.${p.name}().stream().map(${p.type}DTOImpl::of).toList()`)
body.append(`public static ${t.name}DTOImpl of(${artifactConfig.rootPackageName}.service.dto.${t.name}DTO source) {`,NL)
body.indent( mBody => {
mBody.append(`if(source instanceof ${t.name}DTOImpl) {`,NL)
mBody.indent(inner => {
inner.append(`return (${t.name}DTOImpl)source;`,NL)
})
mBody.append('}')
mBody.appendNewLine();
mBody.append(`return new ${t.name}DTOImpl(`,NL);
mBody.indent( inner => {
allProps.forEach( (p, idx, arr) => {
if( isMKeyProperty(p) || isMRevisionProperty(p) || (p.variant !== 'union' && p.variant !== 'record') ) {
inner.append(`source.${p.name}()`)
} else {
inner.append(`${p.type}DTOImpl.of(source.${p.name}())`)
if( p.array ) {
inner.append(`source.${p.name}().stream().map(${p.type}DTOImpl::of).toList()`)
} else {
inner.append(`${p.type}DTOImpl.of(source.${p.name}())`)
}
}
}
if( idx + 1 < arr.length ) {
inner.append(',')
}
inner.appendNewLine()
});
if( idx + 1 < arr.length ) {
inner.append(',')
}
inner.appendNewLine()
});
})

mBody.append(');',NL)
})

body.append(');',NL)
})
node.append('}')
body.append('}')
} )

/*node.appendNewLine();
node.indent( body => {
body.append(`public static class BuilderImpl implements Builder {`, NL);
Expand Down

0 comments on commit ba28baa

Please sign in to comment.