本文整理汇总了Java中com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease类的典型用法代码示例。如果您正苦于以下问题:Java ParcelablePlease类的具体用法?Java ParcelablePlease怎么用?Java ParcelablePlease使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParcelablePlease类属于com.hannesdorfmann.parcelableplease.annotation包,在下文中一共展示了ParcelablePlease类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: abstractClass
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease; //导入依赖的package包/类
@Test
public void abstractClass() {
String annotation = ParcelablePlease.class.getCanonicalName();
JavaFileObject componentFile = JavaFileObjects.forSourceLines("test.AbstractClass",
"package test;",
"",
"@" + annotation,
"abstract class AbstractClass {}");
Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
.that(componentFile).processedWith(new ParcelablePleaseProcessor())
.failsToCompile()
.withErrorContaining("Element AbstractClass is annotated with @ParcelablePlease but is an abstract class. Abstract classes can not be annotated. Annotate the concrete class that implements all abstract methods with @ParcelablePlease");
}
开发者ID:sockeqwe,项目名称:ParcelablePlease,代码行数:17,代码来源:ParcelablePleaseProcessorTest.java
示例2: simpleClass
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease; //导入依赖的package包/类
@Test
public void simpleClass() {
String annotation = ParcelablePlease.class.getCanonicalName();
JavaFileObject componentFile = JavaFileObjects.forSourceLines("test.SimpleClass",
"package test;",
"",
"@" + annotation,
"class SimpleClass {" +
"int id;" +
"String name;" +
"}");
Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
.that(componentFile).processedWith(new ParcelablePleaseProcessor())
.compilesWithoutError();
}
开发者ID:sockeqwe,项目名称:ParcelablePlease,代码行数:18,代码来源:ParcelablePleaseProcessorTest.java
示例3: innerClass
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease; //导入依赖的package包/类
@Test
public void innerClass() {
String annotation = ParcelablePlease.class.getCanonicalName();
JavaFileObject componentFile = JavaFileObjects.forSourceLines("test.OuterClass",
"package test;",
"",
"class OuterClass {",
"@" + annotation,
"class InnerClass {",
"int id;",
"String name;" ,
"}",
"}");
Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
.that(componentFile).processedWith(new ParcelablePleaseProcessor())
.compilesWithoutError();
}
开发者ID:sockeqwe,项目名称:ParcelablePlease,代码行数:20,代码来源:ParcelablePleaseProcessorTest.java
示例4: stringList
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease; //导入依赖的package包/类
@Test
public void stringList() {
String annotation = ParcelablePlease.class.getCanonicalName();
JavaFileObject componentFile = JavaFileObjects.forSourceLines("test.StringListTest",
"package test;",
"",
"@" + annotation,
"class StringListTest {",
" java.util.List<String> strings;",
"}");
Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
.that(componentFile).processedWith(new ParcelablePleaseProcessor())
.compilesWithoutError();
}
开发者ID:sockeqwe,项目名称:ParcelablePlease,代码行数:17,代码来源:ParcelablePleaseProcessorTest.java
示例5: isClass
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease; //导入依赖的package包/类
/**
* Checks if the element is a class
*/
private boolean isClass(Element element) {
if (element.getKind() == ElementKind.CLASS) {
if (element.getModifiers().contains(Modifier.ABSTRACT)) {
ProcessorMessage.error(element,
"Element %s is annotated with @%s but is an abstract class. "
+ "Abstract classes can not be annotated. Annotate the concrete class "
+ "that implements all abstract methods with @%s", element.getSimpleName(),
ParcelablePlease.class.getSimpleName(), ParcelablePlease.class.getSimpleName());
return false;
}
if (element.getModifiers().contains(Modifier.PRIVATE)) {
ProcessorMessage.error(element, "The private class %s is annotated with @%s. "
+ "Private classes are not supported because of lacking visibility.",
element.getSimpleName(), ParcelablePlease.class.getSimpleName());
return false;
}
// Ok, its a valid class
return true;
} else {
ProcessorMessage.error(element,
"Element %s is annotated with @%s but is not a class. Only Classes are supported",
element.getSimpleName(), ParcelablePlease.class.getSimpleName());
return false;
}
}
开发者ID:sockeqwe,项目名称:ParcelablePlease,代码行数:32,代码来源:ParcelablePleaseProcessor.java
示例6: generate
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease; //导入依赖的package包/类
public void generate(TypeElement classElement, List<ParcelableField> fields) throws Exception {
String classSuffix = "ParcelablePlease";
String packageName = TypeUtils.getPackageName(elementUtils, classElement);
String binaryName = TypeUtils.getBinaryName(elementUtils, classElement);
String originFullQualifiedName = classElement.getQualifiedName().toString();
String className;
if (packageName.length() > 0) {
className = binaryName.substring(packageName.length() + 1) + classSuffix;
} else {
className = binaryName + classSuffix;
}
String qualifiedName = binaryName + classSuffix;
//
// Write code
//
JavaFileObject jfo = filer.createSourceFile(qualifiedName, classElement);
Writer writer = jfo.openWriter();
JavaWriter jw = new JavaWriter(writer);
jw.emitPackage(packageName);
jw.emitImports("android.os.Parcel");
jw.emitEmptyLine();
jw.emitJavadoc("Generated class by @%s . Do not modify this code!",
ParcelablePlease.class.getSimpleName());
jw.beginType(className, "class", EnumSet.of(Modifier.PUBLIC));
jw.emitEmptyLine();
generateWriteToParcel(jw, originFullQualifiedName, fields);
jw.emitEmptyLine();
generateReadFromParcel(jw, originFullQualifiedName, fields);
jw.endType();
jw.close();
}
开发者ID:sockeqwe,项目名称:ParcelablePlease,代码行数:38,代码来源:CodeGenerator.java
注:本文中的com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论