1111import java .util .List ;
1212import java .util .Map ;
1313
14+ /**
15+ * A request to analyze a string of text for attributes
16+ * @author Ben McLean <ben@origma.com.au>
17+ */
1418public class AnalyzeCommentRequest {
1519
1620 Entry comment ;
@@ -21,89 +25,77 @@ public class AnalyzeCommentRequest {
2125 String clientToken ;
2226 String sessionId ;
2327 Double suggestCommentScore ;
24-
25- public AnalyzeCommentRequest () {
26- super ();
27- }
28-
29- public AnalyzeCommentRequest (Entry comment , Context context , Map <AttributeType , RequestedAttribute > requestedAttributes ,
30- List <String > languages , Boolean doNotStore , String clientToken , String sessionId ,
31- Double suggestCommentScore ) {
32- super ();
33- this .comment = comment ;
34- this .context = context ;
35- this .requestedAttributes = requestedAttributes ;
36- this .languages = languages ;
37- this .doNotStore = doNotStore ;
38- this .clientToken = clientToken ;
39- this .sessionId = sessionId ;
40- this .suggestCommentScore = suggestCommentScore ;
41- }
42-
28+
29+ /**
30+ * Returns the comment to be analyzed by the request
31+ * @return
32+ */
4333 public Entry getComment () {
4434 return comment ;
4535 }
4636
47- public void setComment ( Entry comment ) {
48- this . comment = comment ;
49- }
50-
37+ /**
38+ * Returns the content of the request
39+ * @return the content of the request
40+ */
5141 public Context getContext () {
5242 return context ;
5343 }
5444
55- public void setContext ( Context context ) {
56- this . context = context ;
57- }
58-
45+ /**
46+ * Returns the attributes that will be requested
47+ * @return the attributes that will be requested
48+ */
5949 public Map <AttributeType , RequestedAttribute > getRequestedAttributes () {
6050 return requestedAttributes ;
6151 }
6252
63- public void setRequestedAttributes ( Map < AttributeType , RequestedAttribute > requestedAttributes ) {
64- this . requestedAttributes = requestedAttributes ;
65- }
66-
53+ /**
54+ * Returns the set languages for the request
55+ * @return the set languages for the request
56+ */
6757 public List <String > getLanguages () {
6858 return languages ;
6959 }
70-
71- public void setLanguages ( List < String > languages ) {
72- this . languages = languages ;
73- }
74-
60+
61+ /**
62+ * Returns whether the comment will be stored for analysis or not
63+ * @return whether the comment will be stored for analysis or not
64+ */
7565 public Boolean getDoNotStore () {
7666 return doNotStore ;
7767 }
7868
79- public void setDoNotStore ( Boolean doNotStore ) {
80- this . doNotStore = doNotStore ;
81- }
82-
69+ /**
70+ * Returns the client token of the request
71+ * @return the client token of the request
72+ */
8373 public String getClientToken () {
8474 return clientToken ;
8575 }
8676
87- public void setClientToken ( String clientToken ) {
88- this . clientToken = clientToken ;
89- }
90-
77+ /**
78+ * Returns the session ID of the request
79+ * @return the session ID of the request
80+ */
9181 public String getSessionId () {
9282 return sessionId ;
9383 }
9484
95- public void setSessionId ( String sessionId ) {
96- this . sessionId = sessionId ;
97- }
98-
85+ /**
86+ * Returns the comment score suggested to the analyzer
87+ * @return the comment score suggested to the analyzer
88+ */
9989 public Double getSuggestCommentScore () {
10090 return suggestCommentScore ;
10191 }
10292
103- public void setSuggestCommentScore (Double suggestCommentScore ) {
104- this .suggestCommentScore = suggestCommentScore ;
105- }
106-
93+ /**
94+ * Builds an AnalyzeCommentRequest
95+ *
96+ * @author Ben McLean <ben@origma.com.au>
97+ *
98+ */
10799 public static class Builder {
108100 private Entry comment ;
109101 private Context context ;
@@ -114,60 +106,115 @@ public static class Builder {
114106 private String sessionId ;
115107 private Double suggestCommentScore ;
116108
109+ /**
110+ * Set the comment of the future AnalyzeCommentRequest
111+ * @param comment the comment of the future AnalyzeCommentRequest
112+ * @return The builder
113+ */
117114 public Builder comment (Entry comment ) {
118115 this .comment = comment ;
119116 return this ;
120117 }
121118
119+ /**
120+ * Set the context of the future AnalyzeCommentRequest
121+ * @param context the context of the future AnalyzeCommentRequest
122+ * @return The builder
123+ */
122124 public Builder context (Context context ) {
123125 this .context = context ;
124126 return this ;
125127 }
126128
129+ /**
130+ * Set the requested attributes of the future AnalyzeCommentRequest
131+ * @param requestedAttributes the requested attributes of the future AnalyzeCommentRequest
132+ * @return The builder
133+ */
127134 public Builder requestedAttributes (Map <AttributeType , RequestedAttribute > requestedAttributes ) {
128135 this .requestedAttributes = requestedAttributes ;
129136 return this ;
130137 }
131138
139+ /**
140+ * Add a requested attribute to the future AnalyzeCommentRequest
141+ * @param type The type of the requested attribute
142+ * @param requestedAttribute The parameters of the requested attribute
143+ * @return The builder
144+ */
132145 public Builder addRequestedAttribute (AttributeType type , RequestedAttribute requestedAttribute ) {
133146 if (requestedAttribute != null ){
134147 requestedAttributes .put (type , requestedAttribute );
135148 }else {
136- requestedAttributes .put (type , new RequestedAttribute ());
149+ requestedAttributes .put (type , new RequestedAttribute . Builder (). build ());
137150 }
138151 return this ;
139152 }
140153
154+ /**
155+ * Set the languages of the future AnalyzeCommentRequest
156+ * @param languages the languages of the future AnalyzeCommentRequest in ISO 639-1
157+ * @return The builder
158+ */
141159 public Builder languages (List <String > languages ) {
142160 this .languages = languages ;
143161 return this ;
144162 }
145163
164+ /**
165+ * Add a language to the future AnalyzeCommentRequest
166+ * @param language The language in ISO 639-1
167+ * @return The builder
168+ */
146169 public Builder addLanguage (String language ){
147170 languages .add (language );
148171 return this ;
149172 }
150173
174+ /**
175+ * Set the do not store of the future AnalyzeCommentRequest
176+ * @param doNotStore the do not store of the future AnalyzeCommentRequest
177+ * @return The builder
178+ */
151179 public Builder doNotStore (Boolean doNotStore ) {
152180 this .doNotStore = doNotStore ;
153181 return this ;
154182 }
155183
184+ /**
185+ * Set the client token of the future AnalyzeCommentRequest
186+ * @param clientToken the clientToken of the future AnalyzeCommentRequest
187+ * @return The builder
188+ */
156189 public Builder clientToken (String clientToken ) {
157190 this .clientToken = clientToken ;
158191 return this ;
159192 }
160193
194+ /**
195+ * Set the session ID of the future AnalyzeCommentRequest
196+ * @param sessionId the sessionId of the future AnalyzeCommentRequest
197+ * @return The builder
198+ */
161199 public Builder sessionId (String sessionId ) {
162200 this .sessionId = sessionId ;
163201 return this ;
164202 }
165203
204+ /**
205+ * Set the suggested comment score of the future AnalyzeCommentRequest
206+ * @param suggestCommentScore the suggested comment score of the future AnalyzeCommentRequest
207+ * @return The builder
208+ */
166209 public Builder suggestCommentScore (Double suggestCommentScore ) {
167210 this .suggestCommentScore = suggestCommentScore ;
168211 return this ;
169212 }
170213
214+ /**
215+ * Build and create a new instance of AnalyzeCommentRequest
216+ * @return The builder
217+ */
171218 public AnalyzeCommentRequest build () {
172219 return new AnalyzeCommentRequest (this );
173220 }
0 commit comments