public static @Nullable JavaOverrideImplementMemberChooserContainer prepare(PsiElement aClass,
                                                                              boolean toImplement,
                                                                              Collection<? extends CandidateInfo> candidates,
                                                                              Collection<? extends CandidateInfo> secondary) {
    final Project project = aClass.getProject();
    final PsiFile file = aClass.getContainingFile();
    if (file == null) {
      return null;
    }
    if (candidates.isEmpty() && secondary.isEmpty()) return null;

    final PsiMethodMember[] onlyPrimary = convertToMethodMembers(candidates);
    final LinkedHashSet<CandidateInfo> allCandidates = new LinkedHashSet<>(candidates);
    allCandidates.addAll(secondary);
    final PsiMethodMember[] all = convertToMethodMembers(allCandidates);
    final NotNullLazyValue<PsiMethodWithOverridingPercentMember[]> lazyElementsWithPercent = NotNullLazyValue.lazy(() -> {
      final PsiMethodWithOverridingPercentMember[] elements =
        PsiMethodWithOverridingPercentMember.calculateOverridingPercents(candidates);
      Arrays.sort(elements, PsiMethodWithOverridingPercentMember.COMPARATOR);
      return elements;
    });
    final boolean merge = PropertiesComponent.getInstance(project).getBoolean(PROP_COMBINED_OVERRIDE_IMPLEMENT, true);

    final LanguageLevel languageLevel = PsiUtil.getLanguageLevel(aClass);
    //hide option if implement interface for 1.5 language level
    final boolean overrideVisible =
      JavaFeature.OVERRIDE_INTERFACE.isSufficient(languageLevel) || JavaFeature.ANNOTATIONS.isSufficient(languageLevel) && !toImplement;

    ClassMember[] selectElements = null;
    if (toImplement) {
      if (onlyPrimary.length == 0) {
        selectElements = new ClassMember[]{all[0]};
      }
      else {
        PsiClass currClass = ObjectUtils.tryCast(aClass, PsiClass.class);
        if (currClass != null && currClass.isRecord()) {
          PsiMethodMember[] toImplementMembers = ContainerUtil
            .filter(onlyPrimary, m -> !OverrideImplementExploreUtil.belongsToRecord(m.getElement()))
            .toArray(new PsiMethodMember[0]);
          selectElements = ArrayUtil.isEmpty(toImplementMembers) ? onlyPrimary : toImplementMembers;
        }
        else {
          selectElements = onlyPrimary;
        }
      }
    }
    return new JavaOverrideImplementMemberChooserContainer(project, file, onlyPrimary, all, lazyElementsWithPercent, merge, overrideVisible,
                                                           toImplement, selectElements);
  }
public static @Nullable JavaOverrideImplementMemberChooserContainer prepare(PsiElement aClass,
                                                                              boolean toImplement,
                                                                              Collection<? extends CandidateInfo> candidates,
                                                                              Collection<? extends CandidateInfo> secondary)