@Test public void isSectionClass() { PsiClass section = createSubclassOf("com.facebook.litho.sections.Section"); Assert.assertTrue(LithoPluginUtils.isSectionClass(section)); Assert.assertTrue(LithoPluginUtils.isGeneratedClass(section)); PsiClass notSection = createSubclassOf("com.facebook.litho.sections.SectionTest"); Assert.assertFalse(LithoPluginUtils.isSectionClass(notSection)); Assert.assertFalse(LithoPluginUtils.isGeneratedClass(notSection)); }
public static boolean isSectionClass(@Nullable PsiClass psiClass) { return Optional.ofNullable(psiClass) .map(PsiClass::getSuperClass) .map(PsiClass::getQualifiedName) .filter(LithoClassNames.SECTION_CLASS_NAME::equals) .isPresent(); }
LithoPluginUtils { public static boolean isSectionClass(@Nullable PsiClass psiClass) { return Optional.ofNullable(psiClass) .map(PsiClass::getSuperClass) .map(PsiClass::getQualifiedName) .filter(LithoClassNames.SECTION_CLASS_NAME::equals) .isPresent(); } }
LithoPluginUtils { public static boolean isSectionClass(@Nullable PsiClass psiClass) { return Optional.ofNullable(psiClass) .map(PsiClass::getSuperClass) .map(PsiClass::getQualifiedName) .filter(LithoClassNames.SECTION_CLASS_NAME::equals) .isPresent(); }  }
LithoPluginUtils { public static boolean isSectionClass(@Nullable PsiClass psiClass) { return Optional.ofNullable(psiClass) .map(PsiClass::getSuperClass) .map(PsiClass::getQualifiedName) .filter(LithoClassNames.SECTION_CLASS_NAME::equals) .isPresent(); }  static boolean isComponentClass(@Nullable PsiClass psiClass); static boolean isSectionClass(@Nullable PsiClass psiClass); static boolean isGeneratedClass(@Nullable PsiClass psiClass); static boolean isLithoSpec(@Nullable PsiFile psiFile); static boolean isLithoSpec(@Nullable PsiClass psiClass); static boolean isLayoutSpec(@Nullable PsiClass psiClass); static boolean isMountSpec(@Nullable PsiClass psiClass); static boolean hasLithoComponentSpecAnnotation(@Nullable PsiClass psiClass); static boolean hasLithoSectionSpecAnnotation(PsiClass psiClass); @Contract("null -> false") static boolean isSpecName(@Nullable String clsName); static boolean isPropOrState(PsiParameter parameter); static boolean isProp(PsiParameter parameter); static boolean isState(PsiParameter parameter); static boolean isParam(PsiParameter parameter); static boolean isPropDefault(PsiField field); static boolean isEvent(PsiClass psiClass); @Nullable @Contract("null -> null") static String getLithoComponentNameFromSpec(@Nullable String specName); @Nullable @Contract("null -> null; !null -> !null") static String getLithoComponentSpecNameFromComponent(@Nullable String componentName); static Stream<PsiParameter> getPsiParameterStream(
      @Nullable PsiMethod currentMethod, PsiMethod[] allMethods); static Optional<PsiClass> getFirstLayoutSpec(PsiFile psiFile); static Optional<PsiClass> getFirstClass(PsiFile psiFile, Predicate<PsiClass> classFilter); static void showInfo(String infoMessage, @Nullable Project project); static void showWarning(String infoMessage, @Nullable Project project); @Nullable static String resolveEventName(PsiMethodCallExpression methodCall); }
LithoPluginUtils { public static boolean isSectionClass(@Nullable PsiClass psiClass) { return Optional.ofNullable(psiClass) .map(PsiClass::getSuperClass) .map(PsiClass::getQualifiedName) .filter(LithoClassNames.SECTION_CLASS_NAME::equals) .isPresent(); }  static boolean isComponentClass(@Nullable PsiClass psiClass); static boolean isSectionClass(@Nullable PsiClass psiClass); static boolean isGeneratedClass(@Nullable PsiClass psiClass); static boolean isLithoSpec(@Nullable PsiFile psiFile); static boolean isLithoSpec(@Nullable PsiClass psiClass); static boolean isLayoutSpec(@Nullable PsiClass psiClass); static boolean isMountSpec(@Nullable PsiClass psiClass); static boolean hasLithoComponentSpecAnnotation(@Nullable PsiClass psiClass); static boolean hasLithoSectionSpecAnnotation(PsiClass psiClass); @Contract("null -> false") static boolean isSpecName(@Nullable String clsName); static boolean isPropOrState(PsiParameter parameter); static boolean isProp(PsiParameter parameter); static boolean isState(PsiParameter parameter); static boolean isParam(PsiParameter parameter); static boolean isPropDefault(PsiField field); static boolean isEvent(PsiClass psiClass); @Nullable @Contract("null -> null") static String getLithoComponentNameFromSpec(@Nullable String specName); @Nullable @Contract("null -> null; !null -> !null") static String getLithoComponentSpecNameFromComponent(@Nullable String componentName); static Stream<PsiParameter> getPsiParameterStream(
      @Nullable PsiMethod currentMethod, PsiMethod[] allMethods); static Optional<PsiClass> getFirstLayoutSpec(PsiFile psiFile); static Optional<PsiClass> getFirstClass(PsiFile psiFile, Predicate<PsiClass> classFilter); static void showInfo(String infoMessage, @Nullable Project project); static void showWarning(String infoMessage, @Nullable Project project); @Nullable static String resolveEventName(PsiMethodCallExpression methodCall);  }