2022-12-14 19:38:29 +01:00
|
|
|
package io.gitlab.jfronny.libjf.config.plugin;
|
|
|
|
|
|
|
|
import com.squareup.javapoet.ClassName;
|
|
|
|
import com.squareup.javapoet.TypeName;
|
|
|
|
|
|
|
|
import javax.lang.model.element.TypeElement;
|
|
|
|
|
2023-07-18 17:23:40 +02:00
|
|
|
public record ConfigClass(
|
|
|
|
TypeElement classElement,
|
|
|
|
ClassName className,
|
|
|
|
TypeName typeName,
|
|
|
|
ClassName generatedClassName,
|
|
|
|
String[] referencedConfigs,
|
|
|
|
TypeName tweakerName
|
|
|
|
) {
|
|
|
|
public static ConfigClass of(TypeElement element, String[] referencedConfigs, TypeName tweakerName, boolean hasManifold) {
|
2022-12-14 19:38:29 +01:00
|
|
|
ClassName className = ClassName.get(element);
|
|
|
|
String pkg = hasManifold ? "gsoncompile.extensions." + className.packageName() + "." + className.simpleNames().get(0) : className.packageName();
|
|
|
|
ClassName generatedClassName = ClassName.get(pkg, "JFC_" + className.simpleNames().get(0), className.simpleNames().subList(1, className.simpleNames().size()).toArray(String[]::new));
|
2023-07-18 17:23:40 +02:00
|
|
|
return new ConfigClass(element, ClassName.get(element), TypeName.get(element.asType()), generatedClassName, referencedConfigs, tweakerName);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasTweaker() {
|
|
|
|
return ConfigProcessor.isUsable(tweakerName);
|
2022-12-14 19:38:29 +01:00
|
|
|
}
|
|
|
|
}
|