本文整理汇总了Java中org.greenrobot.greendao.annotation.Entity类的典型用法代码示例。如果您正苦于以下问题:Java Entity类的具体用法?Java Entity怎么用?Java Entity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Entity类属于org.greenrobot.greendao.annotation包,在下文中一共展示了Entity类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSupportedAnnotationTypes
import org.greenrobot.greendao.annotation.Entity; //导入依赖的package包/类
@Override
public Set<String> getSupportedAnnotationTypes() {
return Collections.singleton(Entity.class.getCanonicalName());
}
示例2: process
import org.greenrobot.greendao.annotation.Entity; //导入依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
String daoListQualifiedName = "java.util.List<Class<? extends " +
"org.greenrobot.greendao.AbstractDao<?, ?>>>";
StringBuilder daoCode = new StringBuilder();
daoCode.append("\n")
.append(daoListQualifiedName)
.append(" daoClasses = new java.util.ArrayList();\n\n");
for (Element element : roundEnv.getElementsAnnotatedWith(Entity.class)) {
if (element.getKind() == ElementKind.CLASS) {
String className = packageName + "." + element.getSimpleName()
+ "Dao.class";
daoCode.append("daoClasses.add(")
.append(className)
.append(");\n");
}
}
daoCode.append("\nreturn daoClasses;\n");
TypeVariableName typeVariableName = TypeVariableName.get(daoListQualifiedName, List.class);
MethodSpec createSpec = MethodSpec.methodBuilder("getAllDaos")
.addModifiers(Modifier.PUBLIC, Modifier.STATIC)
.returns(typeVariableName)
.addJavadoc("Returns a List of all the DAOs classes available")
.addCode(daoCode.toString())
.build();
TypeSpec daoSpec = TypeSpec.classBuilder("DaoHelper")
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.addAnnotation(BaseUtil.getGenerationDetails(DaoAnnotationProcessor.class))
.addMethod(createSpec)
.build();
JavaFile javaFile = JavaFile.builder(packageName, daoSpec)
.build();
try {
javaFile.writeTo(filer);
} catch (IOException e) {
e.printStackTrace();
}
return true;
}