@@ -11,36 +11,65 @@ export class InterfaceVisitor extends BaseVisitor {
1111 const { interface : iFace } = context ;
1212 iFace . annotations . forEach ( ( a ) => {
1313 if ( a . name === "service" ) {
14- this . write ( `interface ${ iFace . name } {` ) ;
14+ this . write ( `public interface ${ iFace . name } {` ) ;
1515 this . write ( `\n` ) ;
1616 iFace . operations . forEach ( ( o ) => {
17- this . write ( `\t ${ convertType ( o . type , context . config ) } ${ o . name } (` ) ;
17+ this . write (
18+ `\t public static ${ convertType ( o . type , context . config ) } ${ o . name } (`
19+ ) ;
1820 o . parameters . forEach ( ( p , i ) => {
1921 this . write ( `${ convertType ( p . type , context . config ) } ${ p . name } ` ) ;
2022 if ( i !== o . parameters . length - 1 ) {
2123 this . write ( `, ` ) ;
2224 }
2325 } ) ;
2426 this . write ( `)` ) ;
25- this . write ( ` throws Exception;` ) ;
27+ this . write ( `{` ) ;
28+ this . write ( `\n` ) ;
29+ this . write ( `\t\t` ) ;
30+ if ( o . parameters . length > 0 ) {
31+ this . write ( `return ${ o . parameters [ 0 ] . name } ;` ) ;
32+ } else {
33+ this . write ( `return;` ) ;
34+ }
35+ this . write ( `\n` ) ;
36+ this . write ( `\t }` ) ;
37+ this . write ( `\n` ) ;
2638 this . write ( `\n` ) ;
2739 } ) ;
2840 this . write ( `}` ) ;
2941 }
3042
3143 if ( a . name === "dependency" ) {
32- this . write ( `interface ${ iFace . name } {` ) ;
44+ this . write ( `public interface ${ iFace . name } {` ) ;
3345 this . write ( `\n` ) ;
3446 iFace . operations . forEach ( ( o ) => {
35- this . write ( `\t ${ convertType ( o . type , context . config ) } ${ o . name } (` ) ;
47+ this . write (
48+ `\t public static ${ convertType ( o . type , context . config ) } ${ o . name } (`
49+ ) ;
3650 o . parameters . forEach ( ( p , i ) => {
3751 this . write ( `${ p . name } ${ convertType ( p . type , context . config ) } ` ) ;
3852 if ( i !== o . parameters . length - 1 ) {
3953 this . write ( `, ` ) ;
4054 }
4155 } ) ;
4256 this . write ( `)` ) ;
43- this . write ( ` throws Exception;` ) ;
57+ this . write ( `{` ) ;
58+ this . write ( `\n` ) ;
59+ this . write ( `\t\t` ) ;
60+ if ( o . parameters . length > 0 ) {
61+ this . write ( `return ${ o . parameters [ 0 ] . name } ;` ) ;
62+ } else if (
63+ iFace . operations . length > 0 &&
64+ convertType ( o . type , context . config ) !== "void"
65+ ) {
66+ this . write ( `return null;` ) ;
67+ } else {
68+ this . write ( `return;` ) ;
69+ }
70+ this . write ( `\n` ) ;
71+ this . write ( `\t }` ) ;
72+ this . write ( `\n` ) ;
4473 this . write ( `\n` ) ;
4574 } ) ;
4675 this . write ( `}` ) ;
0 commit comments