Skip to content

Commit f97a1ca

Browse files
committed
[Language-translation] fix issue #240.
1 parent e3b00a5 commit f97a1ca

File tree

2 files changed

+49
-10
lines changed

2 files changed

+49
-10
lines changed

src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslation.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,7 @@
2121
import com.ibm.watson.developer_cloud.http.HttpHeaders;
2222
import com.ibm.watson.developer_cloud.http.HttpMediaType;
2323
import com.ibm.watson.developer_cloud.http.RequestBuilder;
24-
import com.ibm.watson.developer_cloud.language_translation.v2.model.CreateModelOptions;
25-
import com.ibm.watson.developer_cloud.language_translation.v2.model.IdentifiableLanguage;
26-
import com.ibm.watson.developer_cloud.language_translation.v2.model.IdentifiedLanguage;
27-
import com.ibm.watson.developer_cloud.language_translation.v2.model.IdentifiableLanguageList;
28-
import com.ibm.watson.developer_cloud.language_translation.v2.model.TranslationModel;
29-
import com.ibm.watson.developer_cloud.language_translation.v2.model.TranslationModelList;
30-
import com.ibm.watson.developer_cloud.language_translation.v2.model.TranslationResult;
24+
import com.ibm.watson.developer_cloud.language_translation.v2.model.*;
3125
import com.ibm.watson.developer_cloud.service.WatsonService;
3226
import com.ibm.watson.developer_cloud.util.Validate;
3327
import com.squareup.okhttp.MultipartBuilder;
@@ -206,15 +200,14 @@ public List<TranslationModel> getModels(final Boolean showDefault, final String
206200
* @param text the text to identify
207201
* @return the identified language
208202
*/
209-
@SuppressWarnings("unchecked")
210203
public List<IdentifiedLanguage> identify(final String text) {
211204
final Request request = RequestBuilder.post(PATH_IDENTIFY)
212205
.withHeader(HttpHeaders.ACCEPT, HttpMediaType.APPLICATION_JSON)
213206
.withBodyContent(text, HttpMediaType.TEXT_PLAIN).build();
214207

215-
final IdentifiableLanguageList languages = executeRequest(request, IdentifiableLanguageList.class);
208+
final IdentifiedLanguageList languages = executeRequest(request, IdentifiedLanguageList.class);
216209

217-
return (List<IdentifiedLanguage>) (List<?>) languages.getLanguages();
210+
return languages.getLanguages();
218211
}
219212

220213
/**
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Copyright 2015 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
package com.ibm.watson.developer_cloud.language_translation.v2.model;
15+
16+
import java.util.List;
17+
18+
import com.ibm.watson.developer_cloud.language_translation.v2.LanguageTranslation;
19+
import com.ibm.watson.developer_cloud.service.model.GenericModel;
20+
21+
/**
22+
* Identified language list used by the {@link LanguageTranslation} service.
23+
*
24+
*/
25+
public class IdentifiedLanguageList extends GenericModel {
26+
27+
private List<IdentifiedLanguage> languages;
28+
29+
/**
30+
* Gets the languages.
31+
*
32+
* @return the languages
33+
*/
34+
public List<IdentifiedLanguage> getLanguages() {
35+
return languages;
36+
}
37+
38+
/**
39+
* Sets the languages.
40+
*
41+
* @param languages the new languages
42+
*/
43+
public void setLanguages(List<IdentifiedLanguage> languages) {
44+
this.languages = languages;
45+
}
46+
}

0 commit comments

Comments
 (0)