• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ParcelablePlease类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DistanceJoint类代码示例发布时间:2022-05-23
下一篇:
Java StreamingQuery类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap