本文整理汇总了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();
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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)");
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}
示例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();
}
示例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();
}