PsiAnnotation (Project project, boolean pure, String contracts, String mutates) { @NonNls Map<String, String> attrMap = new LinkedHashMap<>(); if (!contracts.isEmpty()) { attrMap.put("value", StringUtil.wrapWithDoubleQuote(contracts)); } if (pure) { attrMap.put("pure", "true"); } else if (!mutates.trim().isEmpty()) { attrMap.put("mutates", StringUtil.wrapWithDoubleQuote(mutates)); } if (attrMap.isEmpty()) { return null; } String attrs = attrMap.keySet().equals(Collections.singleton("value")) ? attrMap.get("value") : EntryStream.of(attrMap).join(" = ").joining(", "); return ProjectBytecodeAnalysis.getInstance(project).createContractAnnotation(attrs); }