Switch to Java 8 (#124)

* Set java version 1.8

* Remove "joda-time" usage
* Remove 'com.google.common.base.Function' usage
* Remove "LinkedListMultimap" usage

* Add guava to the dependencies
This commit is contained in:
Jérémie Bresson 2018-04-18 09:18:46 +02:00 committed by GitHub
parent 186594115f
commit ca89af8080
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 57 additions and 59 deletions

View File

@ -74,8 +74,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
@ -195,6 +195,7 @@
</reporting>
<properties>
<diffutils-version>1.3.0</diffutils-version>
<guava-version>20.0</guava-version>
</properties>
<dependencies>
<dependency>
@ -257,6 +258,11 @@
<artifactId>commons-cli</artifactId>
<version>${commons-cli-version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava-version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>

View File

@ -1,6 +1,5 @@
package org.openapitools.codegen;
import javax.annotation.Nullable;
import java.io.File;
import java.util.*;
import java.util.ArrayList;
@ -8,10 +7,9 @@ import java.util.LinkedHashMap;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.samskivert.mustache.Mustache.Compiler;
import io.swagger.models.Model;
@ -3208,13 +3206,9 @@ public class DefaultCodegen implements CodegenConfig {
* @return camelized string
*/
protected String removeNonNameElementToCamelCase(final String name, final String nonNameElementPattern) {
String result = StringUtils.join(Lists.transform(Lists.newArrayList(name.split(nonNameElementPattern)), new Function<String, String>() {
@Nullable
@Override
public String apply(String input) {
return StringUtils.capitalize(input);
}
}), "");
String result = Arrays.stream(name.split(nonNameElementPattern))
.map(StringUtils::capitalize)
.collect(Collectors.joining(""));
if (result.length() > 0) {
result = result.substring(0, 1).toLowerCase() + result.substring(1);
}

View File

@ -20,7 +20,6 @@ import io.swagger.v3.oas.models.tags.Tag;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
//import org.openapitools.codegen.languages.AbstractJavaCodegen;
import org.openapitools.codegen.utils.ImplementationVersion;
@ -32,6 +31,7 @@ import org.slf4j.LoggerFactory;
import java.io.*;
import java.util.*;
import java.net.*;
import java.time.ZonedDateTime;
public class DefaultGenerator extends AbstractGenerator implements Generator {
protected final Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class);
@ -163,8 +163,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
config.processOpts();
config.preprocessOpenAPI(openAPI);
config.additionalProperties().put("generatorVersion", ImplementationVersion.read());
config.additionalProperties().put("generatedDate", DateTime.now().toString());
config.additionalProperties().put("generatedYear", String.valueOf(DateTime.now().getYear()));
config.additionalProperties().put("generatedDate", ZonedDateTime.now().toString());
config.additionalProperties().put("generatedYear", String.valueOf(ZonedDateTime.now().getYear()));
config.additionalProperties().put("generatorClass", config.getClass().getName());
config.additionalProperties().put("inputSpec", config.getInputSpec());

View File

@ -2,8 +2,6 @@ package org.openapitools.codegen.languages;
import static java.util.Collections.sort;
import com.google.common.collect.LinkedListMultimap;
import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import org.openapitools.codegen.languages.features.GzipFeatures;
@ -515,12 +513,12 @@ public class JavaClientCodegen extends AbstractJavaCodegen
}
public static List<Map<String, Object>> modelInheritanceSupportInGson(List<?> allModels) {
LinkedListMultimap<CodegenModel, CodegenModel> byParent = LinkedListMultimap.create();
for (Object m : allModels) {
Map entry = (Map) m;
CodegenModel parent = ((CodegenModel) entry.get("model")).parentModel;
if (null != parent) {
byParent.put(parent, ((CodegenModel) entry.get("model")));
Map<CodegenModel, List<CodegenModel>> byParent = new LinkedHashMap<>();
for (Object model : allModels) {
Map entry = (Map) model;
CodegenModel parent = ((CodegenModel)entry.get("model")).parentModel;
if(null!= parent) {
byParent.computeIfAbsent(parent, k -> new LinkedList<>()).add((CodegenModel)entry.get("model"));
}
}
List<Map<String, Object>> parentsList = new ArrayList<>();

12
pom.xml
View File

@ -77,9 +77,9 @@
</execution>
</executions> -->
<configuration>
<compilerSource>1.7</compilerSource>
<compilerCompliance>1.7</compilerCompliance>
<compilerTargetPlatform>1.7</compilerTargetPlatform>
<compilerSource>1.8</compilerSource>
<compilerCompliance>1.8</compilerCompliance>
<compilerTargetPlatform>1.8</compilerTargetPlatform>
<lineEnding>LF</lineEnding>
</configuration>
</plugin>
@ -153,8 +153,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
@ -189,7 +189,7 @@
<version>2.10.4</version>
<configuration>
<aggregate>true</aggregate>
<source>1.7</source>
<source>1.8</source>
<encoding>UTF-8</encoding>
<maxmemory>1g</maxmemory>
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>

View File

@ -83,9 +83,9 @@
</execution>
</executions> -->
<configuration>
<compilerSource>1.7</compilerSource>
<compilerCompliance>1.7</compilerCompliance>
<compilerTargetPlatform>1.7</compilerTargetPlatform>
<compilerSource>1.8</compilerSource>
<compilerCompliance>1.8</compilerCompliance>
<compilerTargetPlatform>1.8</compilerTargetPlatform>
<lineEnding>LF</lineEnding>
</configuration>
</plugin>
@ -159,8 +159,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
@ -195,7 +195,7 @@
<version>2.10.4</version>
<configuration>
<aggregate>true</aggregate>
<source>1.7</source>
<source>1.8</source>
<encoding>UTF-8</encoding>
<maxmemory>1g</maxmemory>
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>

View File

@ -81,9 +81,9 @@
</execution>
</executions> -->
<configuration>
<compilerSource>1.7</compilerSource>
<compilerCompliance>1.7</compilerCompliance>
<compilerTargetPlatform>1.7</compilerTargetPlatform>
<compilerSource>1.8</compilerSource>
<compilerCompliance>1.8</compilerCompliance>
<compilerTargetPlatform>1.8</compilerTargetPlatform>
<lineEnding>LF</lineEnding>
</configuration>
</plugin>
@ -157,8 +157,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
@ -193,7 +193,7 @@
<version>2.10.4</version>
<configuration>
<aggregate>true</aggregate>
<source>1.7</source>
<source>1.8</source>
<encoding>UTF-8</encoding>
<maxmemory>1g</maxmemory>
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>

View File

@ -87,9 +87,9 @@
</execution>
</executions> -->
<configuration>
<compilerSource>1.7</compilerSource>
<compilerCompliance>1.7</compilerCompliance>
<compilerTargetPlatform>1.7</compilerTargetPlatform>
<compilerSource>1.8</compilerSource>
<compilerCompliance>1.8</compilerCompliance>
<compilerTargetPlatform>1.8</compilerTargetPlatform>
<lineEnding>LF</lineEnding>
</configuration>
</plugin>
@ -163,8 +163,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
@ -199,7 +199,7 @@
<version>2.10.4</version>
<configuration>
<aggregate>true</aggregate>
<source>1.7</source>
<source>1.8</source>
<encoding>UTF-8</encoding>
<maxmemory>1g</maxmemory>
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>

View File

@ -83,9 +83,9 @@
</execution>
</executions> -->
<configuration>
<compilerSource>1.7</compilerSource>
<compilerCompliance>1.7</compilerCompliance>
<compilerTargetPlatform>1.7</compilerTargetPlatform>
<compilerSource>1.8</compilerSource>
<compilerCompliance>1.8</compilerCompliance>
<compilerTargetPlatform>1.8</compilerTargetPlatform>
<lineEnding>LF</lineEnding>
</configuration>
</plugin>
@ -159,8 +159,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
@ -195,7 +195,7 @@
<version>2.10.4</version>
<configuration>
<aggregate>true</aggregate>
<source>1.7</source>
<source>1.8</source>
<encoding>UTF-8</encoding>
<maxmemory>1g</maxmemory>
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>

View File

@ -77,9 +77,9 @@
</execution>
</executions> -->
<configuration>
<compilerSource>1.7</compilerSource>
<compilerCompliance>1.7</compilerCompliance>
<compilerTargetPlatform>1.7</compilerTargetPlatform>
<compilerSource>1.8</compilerSource>
<compilerCompliance>1.8</compilerCompliance>
<compilerTargetPlatform>1.8</compilerTargetPlatform>
<lineEnding>LF</lineEnding>
</configuration>
</plugin>
@ -153,8 +153,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
@ -189,7 +189,7 @@
<version>2.10.4</version>
<configuration>
<aggregate>true</aggregate>
<source>1.7</source>
<source>1.8</source>
<encoding>UTF-8</encoding>
<maxmemory>1g</maxmemory>
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>