当前位置: 首页>>代码示例>>Java>>正文


Java JavaWriter.emitEmptyLine方法代码示例

本文整理汇总了Java中com.squareup.javawriter.JavaWriter.emitEmptyLine方法的典型用法代码示例。如果您正苦于以下问题:Java JavaWriter.emitEmptyLine方法的具体用法?Java JavaWriter.emitEmptyLine怎么用?Java JavaWriter.emitEmptyLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.squareup.javawriter.JavaWriter的用法示例。


在下文中一共展示了JavaWriter.emitEmptyLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: emitGetExpectedObjectSchemaInfoMap

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
private void emitGetExpectedObjectSchemaInfoMap(JavaWriter writer) throws IOException {
    writer.emitAnnotation("Override");
    writer.beginMethod(
            "Map<Class<? extends RealmModel>, OsObjectSchemaInfo>",
            "getExpectedObjectSchemaInfoMap",
            EnumSet.of(Modifier.PUBLIC));

    writer.emitStatement(
            "Map<Class<? extends RealmModel>, OsObjectSchemaInfo> infoMap = " +
                    "new HashMap<Class<? extends RealmModel>, OsObjectSchemaInfo>(%s)", qualifiedProxyClasses.size());
    for (int i = 0; i < qualifiedProxyClasses.size(); i++) {
        writer.emitStatement("infoMap.put(%s.class, %s.getExpectedObjectSchemaInfo())",
                qualifiedModelClasses.get(i), qualifiedProxyClasses.get(i));
    }
    writer.emitStatement("return infoMap");

    writer.endMethod();
    writer.emitEmptyLine();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:RealmProxyMediatorGenerator.java

示例2: emitMediatorSwitch

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
private void emitMediatorSwitch(ProxySwitchStatement statement, JavaWriter writer, boolean nullPointerCheck)
        throws IOException {
    if (nullPointerCheck) {
        writer.emitStatement("checkClass(clazz)");
        writer.emitEmptyLine();
    }
    if (qualifiedModelClasses.size() == 0) {
        writer.emitStatement("throw getMissingProxyClassException(clazz)");
    } else {
        writer.beginControlFlow("if (clazz.equals(%s.class))", qualifiedModelClasses.get(0));
        statement.emitStatement(0, writer);
        for (int i = 1; i < qualifiedModelClasses.size(); i++) {
            writer.nextControlFlow("else if (clazz.equals(%s.class))", qualifiedModelClasses.get(i));
            statement.emitStatement(i, writer);
        }
        writer.nextControlFlow("else");
        writer.emitStatement("throw getMissingProxyClassException(clazz)");
        writer.endControlFlow();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:RealmProxyMediatorGenerator.java

示例3: emitPersistedFieldAccessors

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
private void emitPersistedFieldAccessors(final JavaWriter writer) throws IOException {
    for (final VariableElement field : metadata.getFields()) {
        final String fieldName = field.getSimpleName().toString();
        final String fieldTypeCanonicalName = field.asType().toString();

        if (Constants.JAVA_TO_REALM_TYPES.containsKey(fieldTypeCanonicalName)) {
            emitPrimitiveType(writer, field, fieldName, fieldTypeCanonicalName);
        } else if (Utils.isMutableRealmInteger(field)) {
            emitMutableRealmInteger(writer, field, fieldName, fieldTypeCanonicalName);
        } else if (Utils.isRealmModel(field)) {
            emitRealmModel(writer, field, fieldName, fieldTypeCanonicalName);
        } else if (Utils.isRealmList(field)) {
            final TypeMirror elementTypeMirror = TypeMirrors.getRealmListElementTypeMirror(field);
            emitRealmList(writer, field, fieldName, fieldTypeCanonicalName, elementTypeMirror);
        } else {
            throw new UnsupportedOperationException(String.format(Locale.US,
                    "Field \"%s\" of type \"%s\" is not supported.", fieldName, fieldTypeCanonicalName));
        }

        writer.emitEmptyLine();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:RealmProxyClassGenerator.java

示例4: generate

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
public void generate() throws IOException {
    String qualifiedGeneratedClassName = String.format(Locale.US, "%s.%s", Constants.REALM_PACKAGE_NAME, Constants.DEFAULT_MODULE_CLASS_NAME);
    JavaFileObject sourceFile = env.getFiler().createSourceFile(qualifiedGeneratedClassName);
    JavaWriter writer = new JavaWriter(new BufferedWriter(sourceFile.openWriter()));
    writer.setIndent("    ");

    writer.emitPackage(Constants.REALM_PACKAGE_NAME);
    writer.emitEmptyLine();

    Map<String, Boolean> attributes = new HashMap<String, Boolean>();
    attributes.put("allClasses", Boolean.TRUE);
    writer.emitAnnotation(RealmModule.class, attributes);
    writer.beginType(
            qualifiedGeneratedClassName,        // full qualified name of the item to generate
            "class",                            // the type of the item
            Collections.<Modifier>emptySet(),   // modifiers to apply
            null);                              // class to extend
    writer.emitEmptyLine();

    writer.endType();
    writer.close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:DefaultModuleGenerator.java

示例5: generateTo

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
final void generateTo(final Writer out) throws IOException {
  JavaWriter w = new JavaWriter(out);

  w.emitSingleLineComment("Code generated by Enroscar. Do not edit. %s",
      new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(new Date()));
  w.emitPackage(packageName);

  w.emitImports(imports);
  w.emitEmptyLine();

  classJavaDoc(w);
  w.beginType(className, "class", modifiers(operationsClass), extendsClass);
  w.emitEmptyLine();

  writeClassBody(w);

  w.endType();
}
 
开发者ID:stanfy,项目名称:enroscar-async,代码行数:19,代码来源:BaseGenerator.java

示例6: generateParceler

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
public void generateParceler() throws IOException {

        JavaFileObject sourceFile = processingEnv.getFiler().createSourceFile(parcelerName);
        JavaWriter writer = new JavaWriter(sourceFile.openWriter());

        writer.emitPackage(processingEnv.getElementUtils().getPackageOf(
                elementToParcel).getQualifiedName().toString());

        writer.emitImports(getImports());
        writer.emitEmptyLine();
        elementCompressedName = writer.compressType(elementToParcel.getQualifiedName().toString());
        writer.beginType(parcelerName, "class", EnumSet.of(Modifier.PUBLIC, Modifier.FINAL), null,
                         JavaWriter.type(Parceler.class, elementCompressedName));
        writer.emitEmptyLine();

        writeWriteToParcelMethod(writer);
        writer.emitEmptyLine();
        writeReadFromParcelMethod(writer);
        writer.emitEmptyLine();
        writeNewArrayMethod(writer);
        writer.emitEmptyLine();

        writer.endType();
        writer.close();
    }
 
开发者ID:Workday,项目名称:postman,代码行数:26,代码来源:ParcelerGenerator.java

示例7: emitFields

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
private void emitFields(JavaWriter writer) throws IOException {
    writer.emitField("Set<Class<? extends RealmModel>>", "MODEL_CLASSES", EnumSet.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL));
    writer.beginInitializer(true);
    writer.emitStatement("Set<Class<? extends RealmModel>> modelClasses = new HashSet<Class<? extends RealmModel>>(%s)", qualifiedModelClasses.size());
    for (String clazz : qualifiedModelClasses) {
        writer.emitStatement("modelClasses.add(%s.class)", clazz);
    }
    writer.emitStatement("MODEL_CLASSES = Collections.unmodifiableSet(modelClasses)");
    writer.endInitializer();
    writer.emitEmptyLine();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:RealmProxyMediatorGenerator.java

示例8: emitGetClassModelList

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
private void emitGetClassModelList(JavaWriter writer) throws IOException {
    writer.emitAnnotation("Override");
    writer.beginMethod("Set<Class<? extends RealmModel>>", "getModelClasses", EnumSet.of(Modifier.PUBLIC));
    writer.emitStatement("return MODEL_CLASSES");
    writer.endMethod();
    writer.emitEmptyLine();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:RealmProxyMediatorGenerator.java

示例9: emitMediatorShortCircuitSwitch

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
private void emitMediatorShortCircuitSwitch(ProxySwitchStatement statement, JavaWriter writer, boolean nullPointerCheck)
        throws IOException {
    if (nullPointerCheck) {
        writer.emitStatement("checkClass(clazz)");
        writer.emitEmptyLine();
    }
    for (int i = 0; i < qualifiedModelClasses.size(); i++) {
        writer.beginControlFlow("if (clazz.equals(%s.class))", qualifiedModelClasses.get(i));
        statement.emitStatement(i, writer);
        writer.endControlFlow();
    }
    writer.emitStatement("throw getMissingProxyClassException(clazz)");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:RealmProxyMediatorGenerator.java

示例10: emitCreateColumnInfoMethod

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
private void emitCreateColumnInfoMethod(JavaWriter writer) throws IOException {
    writer.beginMethod(
            columnInfoClassName(),        // Return type
            "createColumnInfo",              // Method name
            EnumSet.of(Modifier.PUBLIC, Modifier.STATIC), // Modifiers
            "OsSchemaInfo", "schemaInfo"); // Argument type & argument name

    // create an instance of ColumnInfo
    writer.emitStatement("return new %1$s(schemaInfo)", columnInfoClassName());

    writer.endMethod();
    writer.emitEmptyLine();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:RealmProxyClassGenerator.java

示例11: generateCode

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
public void generateCode(Elements elementUtils, Filer filer) throws IOException {
    TypeElement superClassName = elementUtils.getTypeElement(qualifiedClassName);
    String factoryClassName = superClassName.getSimpleName() + SUFFIX;

    JavaFileObject jfo = filer.createSourceFile(qualifiedClassName + SUFFIX);
    Writer writer = jfo.openWriter();
    JavaWriter jw = new JavaWriter(writer);

    // 写包名
    PackageElement pkg = elementUtils.getPackageOf(superClassName);
    if (!pkg.isUnnamed()) {
        jw.emitPackage(pkg.getQualifiedName().toString());
        jw.emitEmptyLine();
    } else {
        jw.emitPackage("");
    }

    jw.beginType(factoryClassName, "class", EnumSet.of(Modifier.PUBLIC));
    jw.emitEmptyLine();
    jw.beginMethod(qualifiedClassName, "create", EnumSet.of(Modifier.PUBLIC), "String", "id");

    jw.beginControlFlow("if (id == null)");
    jw.emitStatement("throw new IllegalArgumentException(\"id is null!\")");
    jw.endControlFlow();

    for (FactoryAnnotatedClass item : itemsMap.values()) {
        jw.beginControlFlow(String.format("if (\"%s\".equals(id))", item.getId()));
        jw.emitStatement("return new %s()", item.getTypeElement().getQualifiedName().toString());
        jw.endControlFlow();
        jw.emitEmptyLine();
    }

    jw.emitStatement("throw new IllegalArgumentException(\"Unknown id = \" + id)");
    jw.endMethod();
    jw.endType();
    jw.close();
}
 
开发者ID:jacklongway,项目名称:FactoryAnnotation,代码行数:38,代码来源:FactoryGroupedClasses.java

示例12: generateParseMap

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
public void generateParseMap() throws IOException {
    String packageName = packageElement != null
                         ? packageElement.getQualifiedName().toString()
                         : XmlParserSettingsBuilder.DEFAULT_PACKAGE;

    String parserMapClassName = GeneratedClassNames.CLASS_GENERATED_PARSER_MAP;
    String qualifiedClassName = GeneratedClassNames.getQualifiedName(packageName,
                                                                     parserMapClassName);

    JavaFileObject sourceFile = processingEnv.getFiler().createSourceFile(qualifiedClassName);

    JavaWriter writer = new JavaWriter(sourceFile.openWriter());
    writer.emitPackage(packageName);

    writer.emitImports(getParsableClassImports());
    writer.emitEmptyLine();
    writer.emitImports(getJavaImports());
    writer.emitEmptyLine();

    writer.beginType(GeneratedClassNames.CLASS_GENERATED_PARSER_MAP,
                     "class",
                     EnumSet.of(Modifier.PUBLIC, Modifier.FINAL),
                     null,
                     ParserMap.class.getCanonicalName());
    writer.emitEmptyLine();

    writeMapField(writer);
    writer.emitEmptyLine();
    writeGetter(writer);
    writer.emitEmptyLine();
    writeKeySet(writer);

    writer.endType();
    writer.close();
}
 
开发者ID:Workday,项目名称:autoparse-xml,代码行数:36,代码来源:ParserMapGenerator.java

示例13: writeClassBody

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
@Override
protected void writeClassBody(final JavaWriter w) throws IOException {
  w.beginConstructor(constructorModifiers(), "final " + operatorContext(operationsClass), "context");
  w.emitStatement("super(context)");
  w.endConstructor();

  w.emitEmptyLine();

  for (MethodData data : methods) {
    ExecutableElement m = data.method;

    String operationName = m.getSimpleName().toString();

    w.beginMethod(
        data.loaderDescriptionTypeSupport.loaderDescriptionReturnType(w, m, this),
        operationName.concat("IsFinished"),
        EnumSet.of(PUBLIC)
    );
    w.emitStatement(data.loaderDescriptionTypeSupport.loaderDescriptionMethodBody(w, m, this));
    w.endMethod();

    w.beginMethod(
        w.compressType(getFqcn()),
        operationName.concat("IsStartedDo"),
        EnumSet.of(PUBLIC),
        "final Runnable", "action"
    );
    w.emitStatement("addStartAction(%d, action)", getLoaderId(m));
    w.emitStatement("return this");
    w.endMethod();
  }
}
 
开发者ID:stanfy,项目名称:enroscar-async,代码行数:33,代码来源:LoaderDescriptionGenerator.java

示例14: generateParserMap

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
public void generateParserMap() throws IOException {

        String packageName = packageElement != null
                             ? packageElement.getQualifiedName().toString()
                             : JsonParserSettingsBuilder.DEFAULT_OBJECT_PARSER_PACKAGE;

        String qualifiedClassName = GeneratedClassNames.getQualifiedName(packageName,
                                                                         GeneratedClassNames
                                                                                 .CLASS_JSON_OBJECT_PARSER_TABLE);

        JavaFileObject sourceFile = processingEnv.getFiler().createSourceFile(qualifiedClassName);

        JavaWriter writer = new JavaWriter(sourceFile.openWriter());
        writer.emitPackage(packageName);
        writer.emitEmptyLine();
        writer.emitImports(getImports());
        writer.emitEmptyLine();

        writer.beginType(GeneratedClassNames.CLASS_JSON_OBJECT_PARSER_TABLE, "class",
                         EnumSet.of(Modifier.PUBLIC, Modifier.FINAL), null,
                         JsonObjectParserTable.class.getCanonicalName());
        writer.emitEmptyLine();

        writeMapField(writer);
        writer.emitEmptyLine();
        writeGetter(writer);
        writer.emitEmptyLine();
        writeKeySet(writer);
        writer.endType();
        writer.close();
    }
 
开发者ID:Workday,项目名称:autoparse-json,代码行数:32,代码来源:JsonObjectParserTableGenerator.java

示例15: generateTable

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
public void generateTable() throws IOException {
    String packageName = packageElement != null
                         ? packageElement.getQualifiedName().toString()
                         : JsonParserSettingsBuilder.DEFAULT_INSTANCE_UPDATER_PACKAGE;

    String qualifiedClassName = GeneratedClassNames.getQualifiedName(packageName,
                                                                     GeneratedClassNames
                                                                             .CLASS_INSTANCE_UPDATER_TABLE);

    JavaFileObject sourceFile = processingEnv.getFiler().createSourceFile(qualifiedClassName);

    JavaWriter writer = new JavaWriter(sourceFile.openWriter());
    writer.emitPackage(packageName);
    writer.emitEmptyLine();
    writer.emitImports(getImports());
    writer.emitEmptyLine();

    writer.beginType(GeneratedClassNames.CLASS_INSTANCE_UPDATER_TABLE, "class",
                     EnumSet.of(Modifier.PUBLIC, Modifier.FINAL),
                     null, InstanceUpdaterTable.class.getCanonicalName());
    writer.emitEmptyLine();

    writeMapField(writer);
    writer.emitEmptyLine();
    writeGetter(writer);

    writer.endType();
    writer.close();
}
 
开发者ID:Workday,项目名称:autoparse-json,代码行数:30,代码来源:InstanceUpdaterTableGenerator.java


注:本文中的com.squareup.javawriter.JavaWriter.emitEmptyLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。