mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Ignore special kotlin collection types (#2130)
Kotlin prefers(emits compiler warnings if not) the built-in types e.g. Set and MutableSet instead of the java.util.* variety. This patch removes the imports for those, so the built-in varieties are used.
This commit is contained in:
+21
@@ -8,6 +8,9 @@ import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -42,6 +45,23 @@ class SimpleQueryBeanWriter {
|
||||
"kotlin.Char"
|
||||
};
|
||||
|
||||
// These are special classes under Kotlin, and are auto-imported, same as
|
||||
// java.lang under Java
|
||||
private static final Set<String> kotlinBlackListedImports = Collections.unmodifiableSet(
|
||||
new HashSet<>(
|
||||
Arrays.asList(
|
||||
"java.util.ArrayList",
|
||||
"java.util.HashMap",
|
||||
"java.util.HashSet",
|
||||
"java.util.LinkedHashMap",
|
||||
"java.util.LinkedHashSet",
|
||||
"java.util.List",
|
||||
"java.util.Map",
|
||||
"java.util.Set"
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
private final Set<String> importTypes = new TreeSet<>();
|
||||
|
||||
private final List<PropertyMeta> properties = new ArrayList<>();
|
||||
@@ -158,6 +178,7 @@ class SimpleQueryBeanWriter {
|
||||
importTypes.add(kotlinTypes[i]);
|
||||
}
|
||||
}
|
||||
importTypes.removeAll(kotlinBlackListedImports);
|
||||
}
|
||||
|
||||
private boolean isEntity() {
|
||||
|
||||
Reference in New Issue
Block a user