*/
public JavaClass findClass(String className) {
synchronized (loadedClasses) {
- if (loadedClasses.containsKey(className)) {
- return loadedClasses.get(className);
- } else {
- return null;
- }
+ return loadedClasses.getOrDefault(className, null);
}
}
}
// 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);
// 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);
}
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);
}
}
}
String tname = target.getName();
String pname = newParent.getName();
- List<String> newparents = declareParentsMap.get(tname);
- if (newparents == null) {
- newparents = new ArrayList<>();
- declareParentsMap.put(tname, newparents);
- }
+ List<String> newparents = declareParentsMap.computeIfAbsent(tname, k -> new ArrayList<>());
newparents.add(pname);
AsmRelationshipProvider.addRelationship(model, weaver.getLazyClassGen().getType(), munger, declaringAspect);
}