aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core
diff options
context:
space:
mode:
authorLars Grefer <eclipse@larsgrefer.de>2020-08-15 16:25:42 +0200
committerLars Grefer <eclipse@larsgrefer.de>2020-08-15 16:36:00 +0200
commit2debfa05f43a6fe71e7bc141f4f78c66f85c95b0 (patch)
tree0b536ac7ef2a5222c7382bc3d03f7023fb5c295d /org.aspectj.ajdt.core
parentd66bec041a857bc3076a20dfeb1aa6037b020db1 (diff)
downloadaspectj-2debfa05f43a6fe71e7bc141f4f78c66f85c95b0.tar.gz
aspectj-2debfa05f43a6fe71e7bc141f4f78c66f85c95b0.zip
Single Map method can be used
Reports common usage patterns of java.util.Map that could be replaced with Java 8 methods: getOrDefault(), computeIfAbsent(), putIfAbsent(), merge(), or replaceAll(). Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java6
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PushinCollector.java18
2 files changed, 4 insertions, 20 deletions
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java
index 68fc6f74f..a8be5eee7 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java
@@ -172,11 +172,7 @@ public class AccessForInlineVisitor extends ASTVisitor {
}
// Avoid repeatedly building ResolvedMembers by using info on any done previously in this visitor
- Map<FieldBinding, ResolvedMember> alreadyResolvedMembers = alreadyProcessedReceivers.get(receiverType);
- if (alreadyResolvedMembers == null) {
- alreadyResolvedMembers = new HashMap<>();
- alreadyProcessedReceivers.put(receiverType, alreadyResolvedMembers);
- }
+ Map<FieldBinding, ResolvedMember> alreadyResolvedMembers = alreadyProcessedReceivers.computeIfAbsent(receiverType, k -> new HashMap<>());
ResolvedMember m = alreadyResolvedMembers.get(binding);
if (m == null) {
m = world.makeResolvedMember(binding, receiverType);
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PushinCollector.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PushinCollector.java
index 894492bf3..2730b5b58 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PushinCollector.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PushinCollector.java
@@ -253,20 +253,12 @@ public class PushinCollector {
// can be null for binary weave (there is no source method)
return;
}
- List<AbstractMethodDeclaration> amds = newDeclarations.get(sourceType);
- if (amds == null) {
- amds = new ArrayList<>();
- newDeclarations.put(sourceType, amds);
- }
+ List<AbstractMethodDeclaration> amds = newDeclarations.computeIfAbsent(sourceType, k -> new ArrayList<>());
amds.add(sourceMethod);
}
public void tagAsMunged(SourceTypeBinding sourceType, String annotationString) {
- List<String> annos = additionalAnnotations.get(sourceType);
- if (annos == null) {
- annos = new ArrayList<>();
- additionalAnnotations.put(sourceType, annos);
- }
+ List<String> annos = additionalAnnotations.computeIfAbsent(sourceType, k -> new ArrayList<>());
annos.add(annotationString);
}
@@ -320,11 +312,7 @@ public class PushinCollector {
public void tagAsMunged(SourceTypeBinding sourceType, TypePattern typePattern) {
if (typePattern instanceof ExactTypePattern) {
- List<ExactTypePattern> annos = additionalParents.get(sourceType);
- if (annos == null) {
- annos = new ArrayList<>();
- additionalParents.put(sourceType, annos);
- }
+ List<ExactTypePattern> annos = additionalParents.computeIfAbsent(sourceType, k -> new ArrayList<>());
annos.add((ExactTypePattern) typePattern);
}
}