本文整理匯總了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;
}