/*
 * Copyright 2014-present Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.facebook.litho.specmodels.processor;

import com.facebook.litho.specmodels.internal.ImmutableList;
import com.facebook.litho.specmodels.model.SpecElementType;
import com.sun.tools.javac.code.Symbol;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;

public class SpecElementTypeDeterminator {
  static boolean isKotlinSingleton(TypeElement element) {
    return element.getKind() == ElementKind.CLASS
        && element
            .getEnclosedElements()
            .stream()
            .anyMatch(
                e -> {
                  final CharSequence instanceFieldName = "INSTANCE";
                  return e.getSimpleName().contentEquals(instanceFieldName)
                      && e.asType().toString().equals(((Symbol.ClassSymbol) element).className())
                      && e.getModifiers()
                          .containsAll(
                              ImmutableList.of(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL));
                });
  }

  public static SpecElementType determine(TypeElement element) {
    if (isKotlinSingleton(element)) {
      return SpecElementType.KOTLIN_SINGLETON;
    }

    return SpecElementType.JAVA_CLASS;
  }
}

@@ -773,48 +773,8 @@
 pe;%0A
-import com.sun.tools.javac.code.Symbol;%0A
 impo
@@ -814,16 +814,16 @@
 ntKind;%0A
+
 import j
@@ -1071,29 +1071,16 @@
  element
-%0A            
 .getEncl
@@ -1093,29 +1093,16 @@
 ements()
-%0A            
 .stream(
@@ -1352,48 +1352,43 @@
 als(
-((Symbol.ClassSymbol) element).className
+element.getQualifiedName().toString
 ())%0A

Remove dependency on javac from SpecElementTypeDeterminator