Skip to content

Commit

Permalink
[issue #937] Refactored the support for guava’s ImmutableTable.
Browse files Browse the repository at this point in the history
  • Loading branch information
rzwitserloot committed Nov 17, 2015
1 parent 6a00335 commit b235bb4
Show file tree
Hide file tree
Showing 15 changed files with 342 additions and 250 deletions.
16 changes: 8 additions & 8 deletions src/core/lombok/core/GuavaTypeMap.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/*
* Copyright (C) 2015 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -28,7 +28,7 @@
public final class GuavaTypeMap {
private static final Map<String, String> TYPE_TO_GUAVA_TYPE; static {
Map<String, String> m = new HashMap<String, String>();

m.put("java.util.NavigableSet", "ImmutableSortedSet");
m.put("java.util.NavigableMap", "ImmutableSortedMap");
m.put("java.util.SortedSet", "ImmutableSortedSet");
Expand All @@ -37,7 +37,7 @@ public final class GuavaTypeMap {
m.put("java.util.Map", "ImmutableMap");
m.put("java.util.Collection", "ImmutableList");
m.put("java.util.List", "ImmutableList");

m.put("com.google.common.collect.ImmutableSet", "ImmutableSet");
m.put("com.google.common.collect.ImmutableSortedSet", "ImmutableSortedSet");
m.put("com.google.common.collect.ImmutableMap", "ImmutableMap");
Expand All @@ -46,14 +46,14 @@ public final class GuavaTypeMap {
m.put("com.google.common.collect.ImmutableList", "ImmutableList");
m.put("com.google.common.collect.ImmutableCollection", "ImmutableList");
m.put("com.google.common.collect.ImmutableTable", "ImmutableTable");

TYPE_TO_GUAVA_TYPE = Collections.unmodifiableMap(m);
}

public static String getGuavaTypeName(String fqn) {
String target = TYPE_TO_GUAVA_TYPE.get(fqn);
return target != null ? target : "ImmutableList";
}

private GuavaTypeMap() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,27 @@ public class EclipseGuavaMapSingularizer extends EclipseGuavaSingularizer {
// TODO cgcc.ImmutableClassToInstanceMap
// TODO cgcc.ImmutableRangeMap

private static final LombokImmutableList<String> SUFFIXES =
LombokImmutableList.of("key", "value");
private static final LombokImmutableList<String> SUPPORTED_TYPES = LombokImmutableList.of(
"com.google.common.collect.ImmutableMap",
"com.google.common.collect.ImmutableBiMap",
"com.google.common.collect.ImmutableSortedMap"
);

@Override public LombokImmutableList<String> getSupportedTypes() {
return LombokImmutableList.of(
"com.google.common.collect.ImmutableMap",
"com.google.common.collect.ImmutableBiMap",
"com.google.common.collect.ImmutableSortedMap");
return SUPPORTED_TYPES;
}

@Override protected LombokImmutableList<String> getArgumentSuffixes() {
return SUFFIXES;
}

@Override protected String getAddMethodName() {
return "put";
}

@Override protected boolean isMap() {
return true;
@Override protected String getAddAllTypeName() {
return "java.util.Map";
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/*
* Copyright (C) 2015 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -30,16 +30,27 @@
public class EclipseGuavaSetListSingularizer extends EclipseGuavaSingularizer {
// TODO com.google.common.collect.ImmutableRangeSet
// TODO com.google.common.collect.ImmutableMultiset and com.google.common.collect.ImmutableSortedMultiset
private static final LombokImmutableList<String> SUFFIXES = LombokImmutableList.of("");
private static final LombokImmutableList<String> SUPPORTED_TYPES = LombokImmutableList.of(
"com.google.common.collect.ImmutableCollection",
"com.google.common.collect.ImmutableList",
"com.google.common.collect.ImmutableSet",
"com.google.common.collect.ImmutableSortedSet"
);

@Override public LombokImmutableList<String> getSupportedTypes() {
return LombokImmutableList.of(
"com.google.common.collect.ImmutableCollection",
"com.google.common.collect.ImmutableList",
"com.google.common.collect.ImmutableSet",
"com.google.common.collect.ImmutableSortedSet",
"com.google.common.collect.ImmutableTable");
return SUPPORTED_TYPES;
}

@Override protected boolean isMap() {
return false;

@Override protected LombokImmutableList<String> getArgumentSuffixes() {
return SUFFIXES;
}

@Override protected String getAddMethodName() {
return "add";
}

@Override protected String getAddAllTypeName() {
return "java.lang.Iterable";
}
}
Loading

0 comments on commit b235bb4

Please sign in to comment.