1 | package com.ether; |
---|
2 | |
---|
3 | import com.ether.annotation.ControllerMethod; |
---|
4 | import org.jetbrains.annotations.NotNull; |
---|
5 | import org.jetbrains.annotations.Nullable; |
---|
6 | |
---|
7 | import java.lang.reflect.Method; |
---|
8 | import java.util.ArrayList; |
---|
9 | import java.util.List; |
---|
10 | |
---|
11 | public class MethodDescription |
---|
12 | { |
---|
13 | MethodDescription( @NotNull final Method method, @NotNull final ControllerMethod annotation ) |
---|
14 | { |
---|
15 | _method = method; |
---|
16 | _view = annotation.view(); |
---|
17 | _defaultView = annotation.defaultView(); |
---|
18 | _isJsonResult = annotation.jsonResult(); |
---|
19 | _isLoginMandatory = annotation.loginMandatory(); |
---|
20 | _isRequestMandatory = annotation.requestMandatory(); |
---|
21 | _isBackofficeMethod = annotation.backofficeMethod(); |
---|
22 | _params = new ArrayList<ParamDescription>(); |
---|
23 | } |
---|
24 | |
---|
25 | public void addNullParam() |
---|
26 | { |
---|
27 | _params.add( null ); |
---|
28 | } |
---|
29 | |
---|
30 | public void addParam( @NotNull final String paramName, @NotNull final Class<?> paramType, final boolean mandatory, final boolean usingJSON ) |
---|
31 | { |
---|
32 | _params.add( new ParamDescription( paramName, paramType, mandatory, usingJSON ) ); |
---|
33 | } |
---|
34 | |
---|
35 | @NotNull |
---|
36 | public String getView() |
---|
37 | { |
---|
38 | return _view; |
---|
39 | } |
---|
40 | |
---|
41 | @Nullable |
---|
42 | public String getDefaultView() |
---|
43 | { |
---|
44 | return _defaultView; |
---|
45 | } |
---|
46 | |
---|
47 | public void setDefaultView( @Nullable final String defaultView ) |
---|
48 | { |
---|
49 | _defaultView = defaultView; |
---|
50 | } |
---|
51 | |
---|
52 | @NotNull |
---|
53 | public Method getMethod() |
---|
54 | { |
---|
55 | return _method; |
---|
56 | } |
---|
57 | |
---|
58 | public Boolean isJsonResult() |
---|
59 | { |
---|
60 | return _isJsonResult; |
---|
61 | } |
---|
62 | |
---|
63 | @Nullable |
---|
64 | public List<ParamDescription> getParams() |
---|
65 | { |
---|
66 | return _params; |
---|
67 | } |
---|
68 | |
---|
69 | public String getName() |
---|
70 | { |
---|
71 | return _method.getName(); |
---|
72 | } |
---|
73 | |
---|
74 | @Override |
---|
75 | public String toString() |
---|
76 | { |
---|
77 | return _method.toString(); |
---|
78 | } |
---|
79 | |
---|
80 | public Boolean isLoginMandatory() |
---|
81 | { |
---|
82 | return _isLoginMandatory; |
---|
83 | } |
---|
84 | |
---|
85 | public void setLoginMandatory( final Boolean loginMandatory ) |
---|
86 | { |
---|
87 | _isLoginMandatory = loginMandatory; |
---|
88 | } |
---|
89 | |
---|
90 | public Boolean isRequestMandatory() |
---|
91 | { |
---|
92 | return _isRequestMandatory; |
---|
93 | } |
---|
94 | |
---|
95 | public void setRequestMandatory( final Boolean requestMandatory ) |
---|
96 | { |
---|
97 | _isRequestMandatory = requestMandatory; |
---|
98 | } |
---|
99 | |
---|
100 | public Boolean isBackofficeMethod() |
---|
101 | { |
---|
102 | return _isBackofficeMethod; |
---|
103 | } |
---|
104 | |
---|
105 | public void setBackofficeMethod( final Boolean backofficeMethod ) |
---|
106 | { |
---|
107 | _isBackofficeMethod = backofficeMethod; |
---|
108 | } |
---|
109 | |
---|
110 | @NotNull |
---|
111 | private Method _method; |
---|
112 | @NotNull |
---|
113 | private String _view; |
---|
114 | @Nullable |
---|
115 | private String _defaultView; |
---|
116 | private Boolean _isJsonResult; |
---|
117 | @Nullable |
---|
118 | private List<ParamDescription> _params; |
---|
119 | private Boolean _isLoginMandatory; |
---|
120 | private Boolean _isRequestMandatory; |
---|
121 | private Boolean _isBackofficeMethod; |
---|
122 | } |
---|