aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse/handlers/singulars
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lombok/eclipse/handlers/singulars')
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java19
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSingularizer.java12
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java14
-rw-r--r--src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilSetSingularizer.java16
4 files changed, 55 insertions, 6 deletions
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
index 54c059b8..642ba9b7 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
@@ -63,6 +63,9 @@ import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
+ protected static final char[] OF = {'o', 'f'};
+ protected static final char[][] CGCC = {{'c', 'o', 'm'}, {'g', 'o', 'o', 'g', 'l', 'e'}, {'c', 'o', 'm', 'm', 'o', 'n'}, {'c', 'o', 'l', 'l', 'e', 'c', 't'}};
+
protected String getSimpleTargetTypeName(SingularData data) {
return GuavaTypeMap.getGuavaTypeName(data.getTargetFqn());
}
@@ -75,15 +78,23 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
protected char[][] makeGuavaTypeName(String simpleName, boolean addBuilder) {
char[][] tokenizedName = new char[addBuilder ? 6 : 5][];
- tokenizedName[0] = new char[] {'c', 'o', 'm'};
- tokenizedName[1] = new char[] {'g', 'o', 'o', 'g', 'l', 'e'};
- tokenizedName[2] = new char[] {'c', 'o', 'm', 'm', 'o', 'n'};
- tokenizedName[3] = new char[] {'c', 'o', 'l', 'l', 'e', 'c', 't'};
+ tokenizedName[0] = CGCC[0];
+ tokenizedName[1] = CGCC[1];
+ tokenizedName[2] = CGCC[2];
+ tokenizedName[3] = CGCC[3];
tokenizedName[4] = simpleName.toCharArray();
if (addBuilder) tokenizedName[5] = new char[] { 'B', 'u', 'i', 'l', 'd', 'e', 'r'};
return tokenizedName;
}
+ @Override protected char[] getEmptyMakerSelector(String targetFqn) {
+ return OF;
+ }
+
+ @Override protected char[][] getEmptyMakerReceiver(String targetFqn) {
+ return CGCC;
+ }
+
@Override public List<EclipseNode> generateFields(SingularData data, EclipseNode builderType) {
String simpleTypeName = getSimpleTargetTypeName(data);
char[][] tokenizedName = makeGuavaTypeName(simpleTypeName, true);
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSingularizer.java
index 80d49fe7..7ea04821 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 The Project Lombok Authors.
+ * Copyright (C) 2015-2019 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -55,6 +55,16 @@ public class EclipseJavaUtilListSingularizer extends EclipseJavaUtilListSetSingu
return LombokImmutableList.of("java.util.List", "java.util.Collection", "java.lang.Iterable");
}
+ private static final char[] EMPTY_LIST = {'e', 'm', 'p', 't', 'y', 'L', 'i', 's', 't'};
+
+ @Override protected char[][] getEmptyMakerReceiver(String targetFqn) {
+ return JAVA_UTIL_COLLECTIONS;
+ }
+
+ @Override protected char[] getEmptyMakerSelector(String targetFqn) {
+ return EMPTY_LIST;
+ }
+
@Override public void appendBuildCode(SingularData data, EclipseNode builderType, List<Statement> statements, char[] targetVariableName, String builderVariable) {
if (useGuavaInstead(builderType)) {
guavaListSetSingularizer.appendBuildCode(data, builderType, statements, targetVariableName, builderVariable);
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
index 9ad1b6fe..b642522f 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
@@ -68,6 +68,20 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
return LombokImmutableList.of("java.util.Map", "java.util.SortedMap", "java.util.NavigableMap");
}
+ private static final char[] EMPTY_SORTED_MAP = {'e', 'm', 'p', 't', 'y', 'S', 'o', 'r', 't', 'e', 'd', 'M', 'a', 'p'};
+ private static final char[] EMPTY_NAVIGABLE_MAP = {'e', 'm', 'p', 't', 'y', 'N', 'a', 'v', 'i', 'g', 'a', 'b', 'l', 'e', 'M', 'a', 'p'};
+ private static final char[] EMPTY_MAP = {'e', 'm', 'p', 't', 'y', 'M', 'a', 'p'};
+
+ @Override protected char[][] getEmptyMakerReceiver(String targetFqn) {
+ return JAVA_UTIL_COLLECTIONS;
+ }
+
+ @Override protected char[] getEmptyMakerSelector(String targetFqn) {
+ if (targetFqn.endsWith("SortedMap")) return EMPTY_SORTED_MAP;
+ if (targetFqn.endsWith("NavigableMap")) return EMPTY_NAVIGABLE_MAP;
+ return EMPTY_MAP;
+ }
+
@Override public List<char[]> listFieldsToBeGenerated(SingularData data, EclipseNode builderType) {
if (useGuavaInstead(builderType)) {
return guavaMapSingularizer.listFieldsToBeGenerated(data, builderType);
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilSetSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilSetSingularizer.java
index 200e615e..2076ec7d 100644
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilSetSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilSetSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 The Project Lombok Authors.
+ * Copyright (C) 2015-2019 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -37,6 +37,20 @@ public class EclipseJavaUtilSetSingularizer extends EclipseJavaUtilListSetSingul
return LombokImmutableList.of("java.util.Set", "java.util.SortedSet", "java.util.NavigableSet");
}
+ private static final char[] EMPTY_SORTED_SET = {'e', 'm', 'p', 't', 'y', 'S', 'o', 'r', 't', 'e', 'd', 'S', 'e', 't'};
+ private static final char[] EMPTY_NAVIGABLE_SET = {'e', 'm', 'p', 't', 'y', 'N', 'a', 'v', 'i', 'g', 'a', 'b', 'l', 'e', 'S', 'e', 't'};
+ private static final char[] EMPTY_SET = {'e', 'm', 'p', 't', 'y', 'S', 'e', 't'};
+
+ @Override protected char[][] getEmptyMakerReceiver(String targetFqn) {
+ return JAVA_UTIL_COLLECTIONS;
+ }
+
+ @Override protected char[] getEmptyMakerSelector(String targetFqn) {
+ if (targetFqn.endsWith("SortedSet")) return EMPTY_SORTED_SET;
+ if (targetFqn.endsWith("NavigableSet")) return EMPTY_NAVIGABLE_SET;
+ return EMPTY_SET;
+ }
+
@Override public void appendBuildCode(SingularData data, EclipseNode builderType, List<Statement> statements, char[] targetVariableName, String builderVariable) {
if (useGuavaInstead(builderType)) {
guavaListSetSingularizer.appendBuildCode(data, builderType, statements, targetVariableName, builderVariable);