Skip to content

Commit 1c2d065

Browse files
committed
Code reformatting
1 parent 22d7db2 commit 1c2d065

File tree

732 files changed

+62348
-56879
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

732 files changed

+62348
-56879
lines changed

modules/swagger-codegen-cli/pom.xml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<parent>
44
<groupId>io.swagger</groupId>
@@ -16,12 +16,12 @@
1616
<build>
1717
<finalName>swagger-codegen-cli</finalName>
1818
<resources>
19-
<resource>
20-
<directory>src/main/resources</directory>
21-
<excludes>
22-
<exclude>logback.xml</exclude>
23-
</excludes>
24-
</resource>
19+
<resource>
20+
<directory>src/main/resources</directory>
21+
<excludes>
22+
<exclude>logback.xml</exclude>
23+
</excludes>
24+
</resource>
2525
</resources>
2626
<plugins>
2727
<plugin>
@@ -62,7 +62,8 @@
6262
</goals>
6363
<configuration>
6464
<transformers>
65-
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
65+
<transformer
66+
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
6667
</transformers>
6768
</configuration>
6869
</execution>

modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/SwaggerCodegen.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package io.swagger.codegen;
22

3+
import io.airlift.airline.Cli;
4+
import io.airlift.airline.Help;
35
import io.swagger.codegen.cmd.ConfigHelp;
46
import io.swagger.codegen.cmd.Generate;
57
import io.swagger.codegen.cmd.Langs;
68
import io.swagger.codegen.cmd.Meta;
7-
import io.airlift.airline.Cli;
8-
import io.airlift.airline.Help;
99

1010
/**
1111
* User: lanwen
1212
* Date: 24.03.15
1313
* Time: 17:56
14-
*
14+
* <p/>
1515
* Command line interface for swagger codegen
1616
* use `swagger-codegen-cli.jar help` for more info
1717
*
Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
11
package io.swagger.codegen.cmd;
22

3-
import io.swagger.codegen.CliOption;
4-
import io.swagger.codegen.CodegenConfig;
53
import io.airlift.airline.Command;
64
import io.airlift.airline.Option;
5+
import io.swagger.codegen.CliOption;
6+
import io.swagger.codegen.CodegenConfig;
7+
78
import java.util.ServiceLoader;
9+
810
import static java.util.ServiceLoader.load;
911

1012
@Command(name = "config-help", description = "Config help for chosen lang")
1113
public class ConfigHelp implements Runnable {
12-
14+
1315
@Option(name = {"-l", "--lang"}, title = "language", required = true,
1416
description = "language to get config help for")
1517
private String lang;
1618

17-
@Override
18-
public void run() {
19-
System.out.println();
20-
CodegenConfig config = forName(lang);
21-
System.out.println("CONFIG OPTIONS");
22-
for (CliOption langCliOption : config.cliOptions()) {
23-
System.out.println("\t" + langCliOption.getOpt());
24-
System.out.println("\t " + langCliOption.getDescription());
25-
System.out.println();
26-
}
27-
}
28-
2919
/**
3020
* Tries to load config class with SPI first, then with class name directly from classpath
21+
*
3122
* @param name name of config, or full qualified class name in classpath
3223
* @return config class
3324
*/
@@ -46,4 +37,16 @@ private static CodegenConfig forName(String name) {
4637
throw new RuntimeException("Can't load config class with name ".concat(name), e);
4738
}
4839
}
40+
41+
@Override
42+
public void run() {
43+
System.out.println();
44+
CodegenConfig config = forName(lang);
45+
System.out.println("CONFIG OPTIONS");
46+
for (CliOption langCliOption : config.cliOptions()) {
47+
System.out.println("\t" + langCliOption.getOpt());
48+
System.out.println("\t " + langCliOption.getDescription());
49+
System.out.println();
50+
}
51+
}
4952
}

modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package io.swagger.codegen.cmd;
22

3+
import config.Config;
4+
import config.ConfigParser;
5+
import io.airlift.airline.Command;
6+
import io.airlift.airline.Option;
37
import io.swagger.codegen.CliOption;
48
import io.swagger.codegen.ClientOptInput;
59
import io.swagger.codegen.ClientOpts;
610
import io.swagger.codegen.CodegenConfig;
711
import io.swagger.codegen.DefaultGenerator;
812
import io.swagger.models.Swagger;
9-
import config.Config;
10-
import config.ConfigParser;
11-
import io.airlift.airline.Command;
12-
import io.airlift.airline.Option;
1313
import io.swagger.parser.SwaggerParser;
1414
import org.slf4j.Logger;
1515
import org.slf4j.LoggerFactory;
@@ -57,15 +57,37 @@ public class Generate implements Runnable {
5757
"Pass in a URL-encoded string of name:header with a comma separating multiple values")
5858
private String auth;
5959

60-
@Option( name= {"-D"}, title = "system properties", description = "sets specified system properties in " +
60+
@Option(name = {"-D"}, title = "system properties", description = "sets specified system properties in " +
6161
"the format of name=value,name=value")
6262
private String systemProperties;
63-
64-
@Option( name= {"-c", "--config"}, title = "configuration file", description = "Path to json configuration file. " +
63+
64+
@Option(name = {"-c", "--config"}, title = "configuration file", description = "Path to json configuration file. " +
6565
"File content should be in a json format {\"optionKey\":\"optionValue\", \"optionKey1\":\"optionValue1\"...} " +
6666
"Supported options can be different for each language. Run config-help -l {lang} command for language specific config options.")
6767
private String configFile;
6868

69+
/**
70+
* Tries to load config class with SPI first, then with class name directly from classpath
71+
*
72+
* @param name name of config, or full qualified class name in classpath
73+
* @return config class
74+
*/
75+
private static CodegenConfig forName(String name) {
76+
ServiceLoader<CodegenConfig> loader = load(CodegenConfig.class);
77+
for (CodegenConfig config : loader) {
78+
if (config.getName().equals(name)) {
79+
return config;
80+
}
81+
}
82+
83+
// else try to load directly
84+
try {
85+
return (CodegenConfig) Class.forName(name).newInstance();
86+
} catch (Exception e) {
87+
throw new RuntimeException("Can't load config class with name ".concat(name), e);
88+
}
89+
}
90+
6991
@Override
7092
public void run() {
7193
verbosed(verbose);
@@ -84,13 +106,13 @@ public void run() {
84106
if (null != templateDir) {
85107
config.additionalProperties().put(TEMPLATE_DIR_PARAM, new File(templateDir).getAbsolutePath());
86108
}
87-
88-
if(null != configFile){
109+
110+
if (null != configFile) {
89111
Config genConfig = ConfigParser.read(configFile);
90112
if (null != genConfig) {
91113
for (CliOption langCliOption : config.cliOptions()) {
92114
if (genConfig.hasOption(langCliOption.getOpt())) {
93-
config.additionalProperties().put(langCliOption.getOpt(), genConfig.getOption(langCliOption.getOpt()));
115+
config.additionalProperties().put(langCliOption.getOpt(), genConfig.getOption(langCliOption.getOpt()));
94116
}
95117
}
96118
}
@@ -103,18 +125,19 @@ public void run() {
103125
}
104126

105127
private void setSystemProperties() {
106-
if( systemProperties != null && systemProperties.length() > 0 ){
107-
for( String property : systemProperties.split(",")) {
128+
if (systemProperties != null && systemProperties.length() > 0) {
129+
for (String property : systemProperties.split(",")) {
108130
int ix = property.indexOf('=');
109-
if( ix > 0 && ix < property.length()-1 ){
110-
System.setProperty( property.substring(0, ix), property.substring(ix+1) );
131+
if (ix > 0 && ix < property.length() - 1) {
132+
System.setProperty(property.substring(0, ix), property.substring(ix + 1));
111133
}
112134
}
113135
}
114136
}
115137

116138
/**
117139
* If true parameter, adds system properties which enables debug mode in generator
140+
*
118141
* @param verbose - if true, enables debug mode
119142
*/
120143
private void verbosed(boolean verbose) {
@@ -132,25 +155,4 @@ private void verbosed(boolean verbose) {
132155
System.setProperty("debugOperations", "");
133156
System.setProperty("debugSupportingFiles", "");
134157
}
135-
136-
/**
137-
* Tries to load config class with SPI first, then with class name directly from classpath
138-
* @param name name of config, or full qualified class name in classpath
139-
* @return config class
140-
*/
141-
private static CodegenConfig forName(String name) {
142-
ServiceLoader<CodegenConfig> loader = load(CodegenConfig.class);
143-
for (CodegenConfig config : loader) {
144-
if (config.getName().equals(name)) {
145-
return config;
146-
}
147-
}
148-
149-
// else try to load directly
150-
try {
151-
return (CodegenConfig) Class.forName(name).newInstance();
152-
} catch (Exception e) {
153-
throw new RuntimeException("Can't load config class with name ".concat(name), e);
154-
}
155-
}
156158
}

modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Langs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package io.swagger.codegen.cmd;
22

33
import ch.lambdaj.collection.LambdaIterable;
4-
import io.swagger.codegen.CodegenConfig;
54
import io.airlift.airline.Command;
5+
import io.swagger.codegen.CodegenConfig;
66

77
import static ch.lambdaj.Lambda.on;
88
import static ch.lambdaj.collection.LambdaCollections.with;

modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Meta.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import com.google.common.collect.ImmutableList;
55
import com.google.common.collect.ImmutableMap;
66
import com.samskivert.mustache.Mustache;
7-
import io.swagger.codegen.DefaultGenerator;
8-
import io.swagger.codegen.SupportingFile;
97
import io.airlift.airline.Command;
108
import io.airlift.airline.Option;
9+
import io.swagger.codegen.DefaultGenerator;
10+
import io.swagger.codegen.SupportingFile;
1111
import org.apache.commons.io.FileUtils;
1212
import org.apache.commons.lang3.StringUtils;
1313
import org.slf4j.Logger;
@@ -81,8 +81,9 @@ public void run() {
8181
/**
8282
* Converter method to process supporting files: execute with mustache,
8383
* or simply copy to destination directory
84+
*
8485
* @param targetDir - destination directory
85-
* @param data - map with additional params needed to process templates
86+
* @param data - map with additional params needed to process templates
8687
* @return converter object to pass to lambdaj
8788
*/
8889
private Converter<SupportingFile, File> processFiles(final File targetDir, final Map<String, Object> data) {
@@ -121,6 +122,7 @@ public File convert(SupportingFile support) {
121122

122123
/**
123124
* Creates mustache loader for template using classpath loader
125+
*
124126
* @param generator - class with reader getter
125127
* @return loader for template
126128
*/
@@ -135,6 +137,7 @@ public Reader getTemplate(String name) {
135137

136138
/**
137139
* Converts package name to path on file system
140+
*
138141
* @param packageName - package name to convert
139142
* @return relative path
140143
*/
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<configuration>
3-
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4-
<layout class="ch.qos.logback.classic.PatternLayout">
5-
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
6-
</layout>
7-
</appender>
8-
<logger name="io.swagger" level="debug"/>
9-
<root level="error">
10-
<appender-ref ref="STDOUT" />
11-
</root>
2+
<configuration>
3+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4+
<layout class="ch.qos.logback.classic.PatternLayout">
5+
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
6+
</layout>
7+
</appender>
8+
<logger name="io.swagger" level="debug"/>
9+
<root level="error">
10+
<appender-ref ref="STDOUT"/>
11+
</root>
1212
</configuration>

0 commit comments

Comments
 (0)