Skip to content

Commit 1756145

Browse files
committed
fixed import order
1 parent 930e00f commit 1756145

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

translate/src/main/java/com/google/cloud/translate/samples/TranslateText.java

+14-16
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,33 @@
1616

1717
package com.google.cloud.translate.samples;
1818

19-
import java.util.List;
20-
import java.io.PrintStream;
21-
import com.google.common.collect.ImmutableList;
22-
2319
import com.google.cloud.translate.Detection;
20+
import com.google.cloud.translate.Language;
2421
import com.google.cloud.translate.Translate;
2522
import com.google.cloud.translate.Translate.TranslateOption;
26-
import com.google.cloud.translate.Language;
2723
import com.google.cloud.translate.Translation;
2824
import com.google.cloud.translate.testing.RemoteTranslateHelper;
25+
import com.google.common.collect.ImmutableList;
26+
27+
import java.io.PrintStream;
28+
import java.util.List;
2929

3030
public class TranslateText {
3131
private static final Translate TRANSLATE = RemoteTranslateHelper.create().options().service();
3232

3333
/**
34-
* Detect the language of input text
34+
* Detect the language of input text.
3535
*/
3636
public static void detectLanguage(String sourceText, PrintStream out) {
3737
List<Detection> detections = TRANSLATE.detect(ImmutableList.of(sourceText));
3838
System.out.println("Language(s) detected:");
39-
for(Detection detection : detections) {
39+
for (Detection detection : detections) {
4040
out.printf("\t%s\n", detection);
4141
}
4242
}
4343

4444
/**
45-
* Translates the source text in any language to english
45+
* Translates the source text in any language to english.
4646
*/
4747
public static void translateText(String sourceText, PrintStream out) {
4848
Translation translation = TRANSLATE.translate(sourceText);
@@ -51,7 +51,7 @@ public static void translateText(String sourceText, PrintStream out) {
5151
}
5252

5353
/**
54-
* Translate the source text from source to target language
54+
* Translate the source text from source to target language.
5555
*/
5656
public static void translateTextWithOptions(
5757
String sourceText,
@@ -73,7 +73,7 @@ public static void translateTextWithOptions(
7373
public static void displaySupportedLanguages(PrintStream out) {
7474
List<Language> languages = TRANSLATE.listSupportedLanguages();
7575

76-
for(Language language : languages) {
76+
for (Language language : languages) {
7777
out.printf("Name: %s, Code: %s\n", language.name(), language.code());
7878
}
7979
}
@@ -82,21 +82,19 @@ public static void main(String[] args) {
8282
String command = args[0];
8383
String text;
8484

85-
if(command.equals("detect")) {
85+
if (command.equals("detect")) {
8686
text = args[1];
8787
TranslateText.detectLanguage(text, System.out);
88-
}
89-
else if(command.equals("translate")) {
88+
} else if (command.equals("translate")) {
9089
text = args[1];
9190
try {
9291
String sourceLang = args[2];
9392
String targetLang = args[3];
9493
TranslateText.translateTextWithOptions(text, sourceLang, targetLang, System.out);
95-
} catch(ArrayIndexOutOfBoundsException ex) {
94+
} catch (ArrayIndexOutOfBoundsException ex) {
9695
TranslateText.translateText(text, System.out);
9796
}
98-
}
99-
else if(command.equals("langsupport")) {
97+
} else if (command.equals("langsupport")) {
10098
TranslateText.displaySupportedLanguages(System.out);
10199
}
102100
}

translate/src/test/java/com/google/cloud/translate/samples/TranslateTextTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
import org.junit.runner.RunWith;
2323
import org.junit.runners.JUnit4;
2424

25-
import java.util.List;
26-
import java.util.Arrays;
2725
import java.io.ByteArrayOutputStream;
2826
import java.io.PrintStream;
27+
import java.util.Arrays;
28+
import java.util.List;
2929

3030
/**
3131
* Unit tests for {@link Analyze}.
@@ -60,7 +60,7 @@ public class TranslateTextTest {
6060

6161
// Assert
6262
String got = bout.toString();
63-
for(String language : languages) {
63+
for (String language : languages) {
6464
assertThat(got).contains(language);
6565
}
6666
}

0 commit comments

Comments
 (0)