Collection<MemberInfo> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, boolean filterTransient, String includeAnnotationProperty, @Nullable ConfigKey onlyExplicitlyIncludedConfigKey, @NotNull String annotationIncludeFQN, @NotNull String annotationExcludeFQN) { final boolean explicitOf = PsiAnnotationUtil.hasDeclaredProperty(psiAnnotation, "of"); final boolean onlyExplicitlyIncluded = checkOnlyExplicitlyIncluded(psiClass, psiAnnotation, onlyExplicitlyIncludedConfigKey); //Having both exclude and of generates a warning; the exclude parameter will be ignored in that case. final Collection<String> ofProperty; final Collection<String> excludeProperty; if (!explicitOf) { ofProperty = Collections.emptyList(); excludeProperty = makeSet(PsiAnnotationUtil.getAnnotationValues(psiAnnotation, "exclude", String.class)); } else { ofProperty = makeSet(PsiAnnotationUtil.getAnnotationValues(psiAnnotation, "of", String.class)); excludeProperty = Collections.emptyList(); } final Collection<PsiMember> psiMembers = PsiClassUtil.collectClassMemberIntern(psiClass); final Collection<String> fieldNames2BeReplaced = new ArrayList<>(); final List<MemberInfo> result = new ArrayList<>(psiMembers.size()); for (PsiMember psiMember : psiMembers) { final PsiAnnotation includeAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiMember, annotationIncludeFQN); if (null == includeAnnotation) { if (onlyExplicitlyIncluded) { continue; } if (!(psiMember instanceof PsiField psiField)) { continue; } final String fieldName = psiField.getName(); if (ofProperty.contains(fieldName)) { result.add(new MemberInfo(psiField)); continue; } else if (explicitOf) { continue; } if (excludeProperty.contains(fieldName)) { continue; } if (psiField.hasModifierProperty(PsiModifier.STATIC)) { continue; } if ((filterTransient && psiField.hasModifierProperty(PsiModifier.TRANSIENT))) { continue; } if (fieldName.startsWith(LombokUtils.LOMBOK_INTERN_FIELD_MARKER)) { continue; } if (PsiAnnotationSearchUtil.isAnnotatedWith(psiField, annotationExcludeFQN)) { continue; } result.add(new MemberInfo(psiField, fieldName, true)); } else { final String includeNameValue = PsiAnnotationUtil.getStringAnnotationValue(includeAnnotation, includeAnnotationProperty, ""); final String newMemberName; if (StringUtil.isEmptyOrSpaces(includeNameValue)) { newMemberName = psiMember.getName(); } else { newMemberName = includeNameValue; } if ((psiMember instanceof PsiMethod psiMethod)) { if (!psiMethod.hasParameters()) { fieldNames2BeReplaced.add(newMemberName); int memberRank = calcMemberRank(includeAnnotation); result.add(new MemberInfo(psiMethod, psiMethod.getName(), memberRank)); } } else { int memberRank = calcMemberRank(includeAnnotation); result.add(new MemberInfo((PsiField)psiMember, newMemberName, memberRank)); } } } for (String fieldName : fieldNames2BeReplaced) { // delete default-included fields with the same name as an explicit inclusion result.removeIf(memberInfo -> memberInfo.matchDefaultIncludedFieldName(fieldName)); } result.sort(MemberInfo::compareTo); return result; }