
com.bebound.plugins.beapp.poet.AppConfigPoet Maven / Gradle / Ivy
package com.bebound.plugins.beapp.poet;
import com.bebound.plugins.beapp.poet.utils.PoetUtils;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeSpec;
import java.io.IOException;
import javax.lang.model.element.Modifier;
public class AppConfigPoet {
public static TypeSpec generate(int appId, String appKey, String xmlName) throws IOException {
TypeSpec.Builder builder = TypeSpec.classBuilder("AppConfig")
.addModifiers(Modifier.PUBLIC, Modifier.STATIC)
.addSuperinterface(PoetUtils.TYPE_BEAPP_CONFIG);
builder.addMethod(MethodSpec.methodBuilder("getBeAppKey")
.addAnnotation(Override.class)
.addModifiers(Modifier.PUBLIC)
.returns(String.class)
.addStatement("return $S", appKey)
.build());
builder.addMethod(MethodSpec.methodBuilder("getBeAppId")
.addAnnotation(Override.class)
.addModifiers(Modifier.PUBLIC)
.returns(long.class)
.addStatement("return $L", appId)
.build());
builder.addMethod(MethodSpec.methodBuilder("getBeAppManifestResId")
.addAnnotation(Override.class)
.addModifiers(Modifier.PUBLIC)
.returns(int.class)
.addStatement("return $T.xml.$L", ClassName.get("", "R"), xmlName)
.build());
return builder.build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy