@@ -11,36 +11,65 @@ export class InterfaceVisitor extends BaseVisitor {
11
11
const { interface : iFace } = context ;
12
12
iFace . annotations . forEach ( ( a ) => {
13
13
if ( a . name === "service" ) {
14
- this . write ( `interface ${ iFace . name } {` ) ;
14
+ this . write ( `public interface ${ iFace . name } {` ) ;
15
15
this . write ( `\n` ) ;
16
16
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
+ ) ;
18
20
o . parameters . forEach ( ( p , i ) => {
19
21
this . write ( `${ convertType ( p . type , context . config ) } ${ p . name } ` ) ;
20
22
if ( i !== o . parameters . length - 1 ) {
21
23
this . write ( `, ` ) ;
22
24
}
23
25
} ) ;
24
26
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` ) ;
26
38
this . write ( `\n` ) ;
27
39
} ) ;
28
40
this . write ( `}` ) ;
29
41
}
30
42
31
43
if ( a . name === "dependency" ) {
32
- this . write ( `interface ${ iFace . name } {` ) ;
44
+ this . write ( `public interface ${ iFace . name } {` ) ;
33
45
this . write ( `\n` ) ;
34
46
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
+ ) ;
36
50
o . parameters . forEach ( ( p , i ) => {
37
51
this . write ( `${ p . name } ${ convertType ( p . type , context . config ) } ` ) ;
38
52
if ( i !== o . parameters . length - 1 ) {
39
53
this . write ( `, ` ) ;
40
54
}
41
55
} ) ;
42
56
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` ) ;
44
73
this . write ( `\n` ) ;
45
74
} ) ;
46
75
this . write ( `}` ) ;
0 commit comments