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


Java JavaWriter.endMethod方法代码示例

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


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

示例1: emitSetter

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
private void emitSetter(JavaWriter writer, Field field) throws IOException {
    // Setter
    writer.beginMethod(
            "void", // Return type
            "set" + field.name, // Method name
            EnumSet.of(Modifier.PUBLIC), field.type, field.name); // Modifiers
    writer.emitStatement("realmSet$" + field.name + "(" + field.name + ")");
    writer.endMethod();

    // Realm Setter
    writer.beginMethod(
            "void", // Return type
            "realmSet$" + field.name, // Method name
            EnumSet.of(Modifier.PUBLIC), field.type, field.name); // Modifiers
    writer.emitStatement("this." + field.name + "=" + field.name);
    writer.endMethod();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:RealmSyntheticTestClass.java

示例2: emitGetter

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
private void emitGetter(JavaWriter writer, Field field) throws IOException {
    // Getter
    writer.beginMethod(
            field.type, // Return type
            "get" + field.name, // Method name
            EnumSet.of(Modifier.PUBLIC)); // Modifiers
    writer.emitStatement("return realmGet$" + field.name + "()");
    writer.endMethod();

    // Realm Getter
    writer.beginMethod(
            field.type, // Return type
            "realmGet$" + field.name, // Method name
            EnumSet.of(Modifier.PUBLIC)); // Modifiers
    writer.emitStatement("return " + field.name);
    writer.endMethod();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:RealmSyntheticTestClass.java

示例3: 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

示例4: writeWriteToParcelMethod

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
private void writeWriteToParcelMethod(JavaWriter writer) throws IOException {
    List<String> parameters = new ArrayList<>(4);
    parameters.add(elementCompressedName);
    parameters.add("object");
    parameters.add("Parcel");
    parameters.add("dest");

    writer.emitAnnotation(Override.class);
    writer.beginMethod("void", "writeToParcel", Modifiers.PUBLIC, parameters, null);
    writer.emitStatement("Bundle bundle = new Bundle()");

    for (VariableElement field : parceledFields) {
        getSaveStatementWriter(field).writeFieldWriteStatement(field, writer);
    }

    writer.emitStatement("dest.writeBundle(bundle)");
    writer.endMethod();
}
 
开发者ID:Workday,项目名称:postman,代码行数:19,代码来源:ParcelerGenerator.java

示例5: writePostCreateCollectionMethod

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
@Override
public void writePostCreateCollectionMethod(JavaWriter writer) throws IOException {
    String collectionType = writer.compressType(JavaWriter.type(Collection.class, "?"));

    writer.beginMethod("void",
                       "onPostCreateCollection",
                       Modifiers.PRIVATE,
                       parentType,
                       "parent",
                       collectionType,
                       "collection");
    writer.beginControlFlow("for (Object o : collection)");
    writeItemSwitch(writer, "parent", "o");
    writer.endControlFlow();
    writer.endMethod();
}
 
开发者ID:Workday,项目名称:autoparse-json,代码行数:17,代码来源:StandardPostCreateChildBlockWriter.java

示例6: writeReadFromParcelMethod

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
private void writeReadFromParcelMethod(JavaWriter writer) throws IOException {
    writer.emitAnnotation(Override.class);
    writer.beginMethod(elementCompressedName, "readFromParcel", Modifiers.PUBLIC, "Parcel",
                       "parcel");

    writer.emitStatement("%s object = new %s()", elementCompressedName, elementCompressedName);
    writer.emitStatement("Bundle bundle = parcel.readBundle()");
    writer.emitStatement("bundle.setClassLoader(%s.class.getClassLoader())",
                         elementCompressedName);
    for (VariableElement field : parceledFields) {
        getSaveStatementWriter(field).writeFieldReadStatement(field,
                                                              postCreateChildMethods,
                                                              writer);
    }
    writer.emitStatement("return object");
    writer.endMethod();
}
 
开发者ID:Workday,项目名称:postman,代码行数:18,代码来源:ParcelerGenerator.java

示例7: writePostCreateMapMethod

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
@Override
public void writePostCreateMapMethod(JavaWriter writer) throws IOException {
    String mapType = writer.compressType(JavaWriter.type(Map.class, "?", "?"));

    writer.beginMethod("void",
                       "onPostCreateMap",
                       Modifiers.PRIVATE,
                       parentType,
                       "parent",
                       mapType,
                       "map");
    writer.beginControlFlow("for (Object o : map.values())");
    writeItemSwitch(writer, "parent", "o");
    writer.endControlFlow();
    writer.endMethod();

}
 
开发者ID:Workday,项目名称:autoparse-json,代码行数:18,代码来源:StandardPostCreateChildBlockWriter.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: 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

示例10: 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

示例11: writeParseAttributesMethod

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
public void writeParseAttributesMethod(TypeElement classElement,
                                       JavaWriter writer)

        throws IOException {
    List<String> parameters = new ArrayList<String>(4);
    parameters.add(classElement.getSimpleName().toString());
    parameters.add("object");
    parameters.add(XmlStreamReader.class.getSimpleName());
    parameters.add("reader");

    writer.beginMethod("void", "parseAttributes", EnumSet.of(Modifier.PRIVATE), parameters,
                       CollectionUtils.newArrayList(ParseException.class.getSimpleName()));
    writer.emitStatement("Attributes attributes = new Attributes(reader)");

    for (Map.Entry<List<String>, Element> entry : attributesAndElements.getAttributes()
                                                                       .entrySet()) {
        List<String> names = entry.getKey();
        Element attributeElement = entry.getValue();

        writeAttributeAssignment(names, attributeElement, writer);
    }

    Element textContent = attributesAndElements.getTextContentElement();
    writer.emitField("String",
                     "contentString",
                     EnumSet.noneOf(Modifier.class),
                     "attributes.getContentString()");
    writer.beginControlFlow("if (contentString != null)");
    if (textContent instanceof ExecutableElement) {
        writer.emitStatement("object.%s(contentString)", textContent.getSimpleName());
    } else if (textContent instanceof VariableElement) {
        writer.emitStatement("object.%s = contentString", textContent.getSimpleName());
    }
    writer.endControlFlow();
    writer.endMethod();
}
 
开发者ID:Workday,项目名称:autoparse-xml,代码行数:37,代码来源:ParseAttributesMethodWriter.java

示例12: writeGetter

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

        writer.emitAnnotation(Override.class);
        writer.beginMethod(JavaWriter.type(XmlElementParser.class, "?"),
                           "get",
                           EnumSet.of(Modifier.PUBLIC),
                           "String",
                           "name");
        writer.emitStatement("return MAP.get(name)");
        writer.endMethod();
    }
 
开发者ID:Workday,项目名称:autoparse-xml,代码行数:12,代码来源:ParserMapGenerator.java

示例13: writeKeySet

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

        writer.emitAnnotation(Override.class);
        writer.beginMethod(JavaWriter.type(Set.class, "String"), "keySet", Modifiers.PUBLIC);
        writer.emitStatement("return MAP.keySet()");
        writer.endMethod();
    }
 
开发者ID:Workday,项目名称:autoparse-xml,代码行数:8,代码来源:ParserMapGenerator.java

示例14: 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

示例15: writeUpdateFromMapMethod

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
private void writeUpdateFromMapMethod(JavaWriter writer) throws IOException {
    writer.emitAnnotation(Override.class);
    writer.emitAnnotation(SuppressWarnings.class, JavaWriter.stringLiteral("rawtypes"));
    List<String> parameters = CollectionUtils.newArrayList(parsedClassName, "instance",
                                                           JavaWriter.type(Map.class, "String", "Object"), "map",
                                                           JsonParserContext.class.getSimpleName(), "context");

    writer.beginMethod("void", "updateInstanceFromMap", Modifiers.PUBLIC, parameters, null);

    writeUpdateAssignmentsBlock(writer);
    if (selfValueAssignmentInfo != null) {
        writeUpdateSelfValuesBlock(writer);
    }
    writer.endMethod();
}
 
开发者ID:Workday,项目名称:autoparse-json,代码行数:16,代码来源:JsonObjectParserGenerator.java


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