aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac
diff options
context:
space:
mode:
authorEmil Lundberg <emil@emlun.se>2019-01-13 01:12:59 +0100
committerEmil Lundberg <emil@emlun.se>2019-01-13 02:38:14 +0100
commitf6d2933795d9091d0cace8d81df530967d84a779 (patch)
treed9b7d4ef7489a3e6293feda21b46421aa1e06000 /src/core/lombok/javac
parenta633e395883d5d24806204a0c10d2ae5b008b8d8 (diff)
downloadlombok-f6d2933795d9091d0cace8d81df530967d84a779.tar.gz
lombok-f6d2933795d9091d0cace8d81df530967d84a779.tar.bz2
lombok-f6d2933795d9091d0cace8d81df530967d84a779.zip
Pull useGuavaInstead logic up to JavacSingularizer
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r--src/core/lombok/javac/handlers/JavacSingularsRecipes.java7
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java8
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java8
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilSingularizer.java4
4 files changed, 9 insertions, 18 deletions
diff --git a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
index 28f8c69c..6e910b71 100644
--- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
+++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
@@ -32,6 +32,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import lombok.ConfigurationKeys;
import lombok.core.LombokImmutableList;
import lombok.core.SpiLoadUtil;
import lombok.core.TypeLibrary;
@@ -102,7 +103,9 @@ public class JavacSingularsRecipes {
}
public JavacSingularizer getSingularizer(String fqn, JavacNode node) {
- return singularizers.get(fqn).getGuavaInsteadIfNeeded(node);
+ final JavacSingularizer singularizer = singularizers.get(fqn);
+ final boolean useGuavaInstead = Boolean.TRUE.equals(node.getAst().readConfiguration(ConfigurationKeys.SINGULAR_USE_GUAVA));
+ return useGuavaInstead ? singularizer.getGuavaInstead(node) : singularizer;
}
public static final class SingularData {
@@ -155,7 +158,7 @@ public class JavacSingularsRecipes {
public static abstract class JavacSingularizer {
public abstract LombokImmutableList<String> getSupportedTypes();
- protected JavacSingularizer getGuavaInsteadIfNeeded(JavacNode node) {
+ protected JavacSingularizer getGuavaInstead(JavacNode node) {
return this;
}
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
index 856a2295..c5cd0738 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
@@ -45,12 +45,8 @@ import com.sun.tools.javac.util.Name;
abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularizer {
- @Override
- protected JavacSingularizer getGuavaInsteadIfNeeded(JavacNode node) {
- if (useGuavaInstead(node)) {
- return guavaListSetSingularizer;
- }
- return this;
+ @Override protected JavacSingularizer getGuavaInstead(JavacNode node) {
+ return guavaListSetSingularizer;
}
@Override public java.util.List<Name> listFieldsToBeGenerated(SingularData data, JavacNode builderType) {
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
index c2c1f233..69215c11 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
@@ -53,12 +53,8 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
return LombokImmutableList.of("java.util.Map", "java.util.SortedMap", "java.util.NavigableMap");
}
- @Override
- protected JavacSingularizer getGuavaInsteadIfNeeded(JavacNode node) {
- if (useGuavaInstead(node)) {
- return guavaMapSingularizer;
- }
- return this;
+ @Override protected JavacSingularizer getGuavaInstead(JavacNode node) {
+ return guavaMapSingularizer;
}
@Override public java.util.List<Name> listFieldsToBeGenerated(SingularData data, JavacNode builderType) {
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSingularizer.java
index df521fd8..47098467 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSingularizer.java
@@ -42,10 +42,6 @@ abstract class JavacJavaUtilSingularizer extends JavacSingularizer {
protected final JavacSingularizer guavaListSetSingularizer = new JavacGuavaSetListSingularizer();
protected final JavacSingularizer guavaMapSingularizer = new JavacGuavaMapSingularizer();
- protected boolean useGuavaInstead(JavacNode node) {
- return Boolean.TRUE.equals(node.getAst().readConfiguration(ConfigurationKeys.SINGULAR_USE_GUAVA));
- }
-
protected List<JCStatement> createJavaUtilSetMapInitialCapacitySwitchStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, boolean mapMode, String emptyCollectionMethod, String singletonCollectionMethod, String targetType, JCTree source, String builderVariable) {
List<JCExpression> jceBlank = List.nil();
ListBuffer<JCCase> cases = new ListBuffer<JCCase>();