Tabnine Logo
JavaFileWriter.writeFieldDeclaration
Code IndexAdd Tabnine to your IDE (free)

How to use
writeFieldDeclaration
method
in
com.yahoo.aptutils.writer.JavaFileWriter

Best Java code snippets using com.yahoo.aptutils.writer.JavaFileWriter.writeFieldDeclaration (Showing top 20 results out of 315)

origin: yahoo/squidb

  private void writeConstantField(JavaFileWriter writer, DeclaredTypeName containingClassName,
      VariableElement constant) throws IOException {
    JavadocPlugin.writeJavadocFromElement(pluginEnv, writer, constant);
    writer.writeFieldDeclaration(
        utils.getTypeNameFromTypeMirror(constant.asType()),
        constant.getSimpleName().toString(),
        Expressions.staticReference(containingClassName, constant.getSimpleName().toString()),
        TypeConstants.PUBLIC_STATIC_FINAL);
  }
}
origin: yahoo/squidb

@Override
protected void emitPropertiesArray() throws IOException {
  writer.writeFieldDeclaration(TypeConstants.PROPERTY_ARRAY, PROPERTIES_ARRAY_NAME,
      Expressions.staticReference(modelSpec.getModelSuperclass(), PROPERTIES_ARRAY_NAME),
      TypeConstants.PUBLIC_STATIC_FINAL);
}
origin: yahoo/squidb

private void emitUnaliasedPropertyArray() throws IOException {
  writer.writeComment("--- unaliased property references");
  Expression basePropertiesInit = Expressions.block(new Expression() {
    @Override
    public boolean writeExpression(JavaFileWriter writer) throws IOException {
      return emitPropertyReferenceArrayBody(false);
    }
  }, false, false, false, false);
  writer.writeFieldDeclaration(TypeConstants.PROPERTY_ARRAY, BASE_PROPERTY_ARRAY_NAME,
      basePropertiesInit, TypeConstants.PRIVATE_STATIC_FINAL)
      .writeNewline();
}
origin: yahoo/squidb

@Override
public void emitPropertyDeclaration(JavaFileWriter writer) throws IOException {
  if (isDeprecated) {
    writer.writeAnnotation(CoreTypes.DEPRECATED);
  }
  List<Object> constructorArgs = new ArrayList<>();
  constructorArgs.add(TableModelFileWriter.TABLE_MODEL_NAME);
  constructorArgs.add("\"" + columnName + "\"");
  String columnDef = getColumnDefinition();
  if (!AptUtils.isEmpty(columnDef)) {
    constructorArgs.add(columnDef);
  }
  writer.writeFieldDeclaration(getPropertyType(), propertyName,
      Expressions.callConstructor(getPropertyType(), constructorArgs), TypeConstants.PUBLIC_STATIC_FINAL);
}
origin: yahoo/squidb

protected void emitPropertiesArray() throws IOException {
  writer.writeComment("--- allocate properties array");
  writer.writeFieldDeclaration(TypeConstants.PROPERTY_ARRAY, PROPERTIES_ARRAY_NAME,
      Expressions.arrayAllocation(TypeConstants.PROPERTY, 1, getPropertiesArrayLength()),
      TypeConstants.PUBLIC_STATIC_FINAL);
  writer.writeNewline();
}
origin: yahoo/squidb

private void emitSqlTableDeclaration(boolean view) throws IOException {
  writer.writeComment("--- " + (view ? "view" : "subquery") + " declaration");
  String name = "\"" + modelSpec.getSpecAnnotation().viewName().trim() + "\"";
  if (modelSpec.getQueryElement() != null) {
    Expression queryReference = Expressions.staticReference(modelSpec.getModelSpecName(),
        modelSpec.getQueryElement().getSimpleName().toString())
        .callMethod("selectMore", ALIASED_PROPERTY_ARRAY_NAME);
    if (modelSpec.getViewQueryAnnotation().freeze()) {
      queryReference = queryReference.callMethod("freeze");
    }
    writer.writeFieldDeclaration(TypeConstants.QUERY, QUERY_NAME, queryReference,
        TypeConstants.PUBLIC_STATIC_FINAL);
    Expression initializer = constructInitializer(name, view);
    writer.writeFieldDeclaration(view ? TypeConstants.VIEW : TypeConstants.SUBQUERY_TABLE,
        view ? VIEW_NAME : SUBQUERY_NAME, initializer, TypeConstants.PUBLIC_STATIC_FINAL);
  } else {
    writer.writeFieldDeclaration(CoreTypes.JAVA_STRING, view ? "VIEW_NAME" : "SUBQUERY_NAME",
        Expressions.fromString(name), TypeConstants.PUBLIC_STATIC_FINAL);
  }
  writer.writeNewline();
}
origin: yahoo/squidb

@Override
public void afterEmitPropertyDeclaration(JavaFileWriter writer, PropertyGenerator propertyGenerator)
    throws IOException {
  if (propertyGenerator instanceof RowidPropertyGenerator) {
    if (((TableModelSpecWrapper) modelSpec).isVirtualTable()) {
      writer.writeAnnotation(CoreTypes.DEPRECATED);
      writer.writeFieldDeclaration(TypeConstants.LONG_PROPERTY,
          DEFAULT_ID_PROPERTY_NAME,
          Expressions.fromString(DEFAULT_ROWID_PROPERTY_NAME),
          TypeConstants.PUBLIC_STATIC_FINAL);
    }
    writeRowidSupportMethods(writer, propertyGenerator.getPropertyName());
  }
}
origin: yahoo/squidb

@Override
protected void writeSetterBody(JavaFileWriter writer, MethodDeclarationParameters params) throws IOException {
  String argName = params.getArgumentNames().get(0);
  final String argAsString = argName + "AsString";
  Expression condition = Expressions.fromString(argName + " == null");
  Expression ifTrue = Expressions.fromString("null");
  Expression ifFalse = Expressions.callMethodOn(argName, "name");
  writer.writeFieldDeclaration(CoreTypes.JAVA_STRING, argAsString,
      new TernaryExpression(condition, ifTrue, ifFalse));
  writer.writeStatement(Expressions.callMethod("set", propertyName, argAsString));
  writer.writeStringStatement("return this");
}
origin: yahoo/squidb

private void emitTableModelMapper() throws IOException {
  writer.writeComment("--- mappers");
  writer.writeFieldDeclaration(TypeConstants.TABLE_MAPPING_VISITORS, "tableMappingInfo",
      Expressions.callMethod("generateTableMappingVisitors",
          PROPERTIES_ARRAY_NAME, ALIASED_PROPERTY_ARRAY_NAME, BASE_PROPERTY_ARRAY_NAME),
      TypeConstants.PRIVATE_STATIC_FINAL)
      .writeNewline();
  writer.writeAnnotation(CoreTypes.OVERRIDE)
      .beginMethodDefinition(GET_TABLE_MAPPING_VISITORS)
      .writeStringStatement("return tableMappingInfo")
      .finishMethodDefinition();
}
origin: yahoo/squidb

@Override
protected void writeGetterBody(JavaFileWriter writer, MethodDeclarationParameters params) throws IOException {
  final String value = "value";
  writer.writeFieldDeclaration(CoreTypes.JAVA_STRING, value,
      Expressions.callMethod("get", propertyName));
  Expression condition = Expressions.fromString(value + " == null");
  Expression ifTrue = Expressions.fromString("null");
  Expression ifFalse = Expressions.staticMethod(enumType, "valueOf", value);
  TernaryExpression ternary = new TernaryExpression(condition, ifTrue, ifFalse);
  writer.writeStatement(ternary.returnExpr());
}
origin: yahoo/squidb

private void emitTableDeclaration() throws IOException {
  writer.writeComment("--- table declaration");
  List<Object> arguments = new ArrayList<>();
  arguments.add(Expressions.classObject(modelSpec.getGeneratedClassName())); // modelClass
  arguments.add(PROPERTIES_ARRAY_NAME); // properties
  arguments.add("\"" + modelSpec.getSpecAnnotation().tableName().trim() + "\""); // name
  arguments.add(null); // database name, null by default
  if (modelSpec.isVirtualTable()) {
    if (AptUtils.isEmpty(modelSpec.getSpecAnnotation().virtualModule())) {
      modelSpec.logError("virtualModule should be non-empty for virtual table models",
          modelSpec.getModelSpecElement());
    }
    arguments.add("\"" + modelSpec.getSpecAnnotation().virtualModule() + "\"");
  } else if (!AptUtils.isEmpty(modelSpec.getSpecAnnotation().tableConstraint())) {
    arguments.add("\"" + modelSpec.getSpecAnnotation().tableConstraint() + "\"");
  }
  writer.writeFieldDeclaration(modelSpec.getTableType(), TABLE_NAME,
      Expressions.callConstructor(modelSpec.getTableType(), arguments), TypeConstants.PUBLIC_STATIC_FINAL);
  writer.writeFieldDeclaration(TypeConstants.TABLE_MODEL_NAME, TABLE_MODEL_NAME,
      Expressions.callConstructor(TypeConstants.TABLE_MODEL_NAME,
          Expressions.classObject(modelSpec.getGeneratedClassName()),
          Expressions.callMethodOn(TableModelFileWriter.TABLE_NAME, "getName")),
      TypeConstants.PUBLIC_STATIC_FINAL);
  writer.writeNewline();
}
origin: yahoo/squidb

  @Override
  public void afterEmitMethods(JavaFileWriter writer) throws IOException {
    // emit creator for parcelable
    writer.writeComment("--- parcelable helpers");
    List<DeclaredTypeName> genericList = Collections.singletonList(modelSpec.getGeneratedClassName());
    DeclaredTypeName creatorType = TypeConstants.CREATOR.clone();
    DeclaredTypeName modelCreatorType = TypeConstants.MODEL_CREATOR.clone();
    creatorType.setTypeArgs(genericList);
    modelCreatorType.setTypeArgs(genericList);

    writer.writeFieldDeclaration(creatorType,
        "CREATOR", Expressions.callConstructor(modelCreatorType,
            Expressions.classObject(modelSpec.getGeneratedClassName())),
        TypeConstants.PUBLIC_STATIC_FINAL)
        .writeNewline();
  }
}
origin: yahoo/squidb

private void emitAliasedPropertyArray() throws IOException {
  writer.writeComment("--- aliased property references");
  Expression aliasedPropertiesInit = Expressions.block(new Expression() {
    @Override
    public boolean writeExpression(JavaFileWriter writer) throws IOException {
      return emitPropertyReferenceArrayBody(true);
    }
  }, false, false, false, false);
  writer.writeFieldDeclaration(TypeConstants.PROPERTY_ARRAY, ALIASED_PROPERTY_ARRAY_NAME,
      aliasedPropertiesInit, TypeConstants.PUBLIC_STATIC_FINAL)
      .writeNewline();
  writer.beginInitializerBlock(true, true);
  writer.writeStatement(Expressions.callMethod("validateAliasedProperties", ALIASED_PROPERTY_ARRAY_NAME));
  writer.finishInitializerBlock(false, true);
  writer.writeNewline();
}
origin: yahoo/squidb

private void emitSinglePropertyDeclaration(PropertyGenerator generator) throws IOException {
  modelSpec.getPluginBundle().beforeEmitPropertyDeclaration(writer, generator);
  writer.writeFieldDeclaration(generator.getPropertyType(), generator.getPropertyName(),
      Expressions.staticReference(modelSpec.getModelSpecName(), generator.getPropertyName()),
      TypeConstants.PUBLIC_STATIC_FINAL)
      .writeNewline();
  modelSpec.getPluginBundle().afterEmitPropertyDeclaration(writer, generator);
}
origin: yahoo/squidb

private void emitSinglePropertyDeclaration(PropertyGenerator generator, int index) throws IOException {
  modelSpec.getPluginBundle().beforeEmitPropertyDeclaration(writer, generator);
  DeclaredTypeName type = generator.getPropertyType();
  String fieldToQualify = ALIASED_PROPERTY_ARRAY_NAME + "[" + index + "]";
  Expression expressionToCast;
  if (modelSpec.getQueryElement() != null) {
    String callOn = modelSpec.getSpecAnnotation().isSubquery() ? SUBQUERY_NAME : VIEW_NAME;
    expressionToCast = Expressions.callMethodOn(callOn, "qualifyField", fieldToQualify);
  } else {
    expressionToCast = Expressions.reference(fieldToQualify);
  }
  writer.writeFieldDeclaration(type, generator.getPropertyName(),
      expressionToCast.cast(type), TypeConstants.PUBLIC_STATIC_FINAL)
      .writeNewline();
  modelSpec.getPluginBundle().afterEmitPropertyDeclaration(writer, generator);
}
origin: yahoo/squidb

protected void emitDefaultValues() throws IOException {
  writer.writeComment("--- default values");
  writer.writeFieldDeclaration(TypeConstants.VALUES_STORAGE, DEFAULT_VALUES_NAME,
      Expressions.callMethodOn(
          Expressions.callConstructor(modelSpec.getGeneratedClassName()), "newValuesStorage"),
      Modifier.PROTECTED, Modifier.STATIC, Modifier.FINAL);
  if (pluginEnv.hasSquidbOption(PluginEnvironment.OPTIONS_DISABLE_DEFAULT_VALUES)) {
    writer.writeComment("--- property defaults disabled by plugin flag");
  } else {
    writer.beginInitializerBlock(true, true)
        .writeComment("--- put property defaults");
    emitDefaultValuesInitializationBlock();
    writer.finishInitializerBlock(false, true).writeNewline();
  }
  writer.writeAnnotation(CoreTypes.OVERRIDE)
      .beginMethodDefinition(GET_DEFAULT_VALUES_PARAMS)
      .writeStringStatement("return " + DEFAULT_VALUES_NAME)
      .finishMethodDefinition();
}
origin: com.yahoo.squidb/squidb-processor

  private void writeConstantField(JavaFileWriter writer, DeclaredTypeName containingClassName,
      VariableElement constant) throws IOException {
    JavadocPlugin.writeJavadocFromElement(pluginEnv, writer, constant);
    writer.writeFieldDeclaration(
        utils.getTypeNameFromTypeMirror(constant.asType()),
        constant.getSimpleName().toString(),
        Expressions.staticReference(containingClassName, constant.getSimpleName().toString()),
        TypeConstants.PUBLIC_STATIC_FINAL);
  }
}
origin: com.yahoo.squidb/squidb-processor

private void emitUnaliasedPropertyArray() throws IOException {
  writer.writeComment("--- unaliased property references");
  Expression basePropertiesInit = Expressions.block(new Expression() {
    @Override
    public boolean writeExpression(JavaFileWriter writer) throws IOException {
      return emitPropertyReferenceArrayBody(false);
    }
  }, false, false, false, false);
  writer.writeFieldDeclaration(TypeConstants.PROPERTY_ARRAY, BASE_PROPERTY_ARRAY_NAME,
      basePropertiesInit, TypeConstants.PRIVATE_STATIC_FINAL)
      .writeNewline();
}
origin: com.yahoo.squidb/squidb-processor

@Override
protected void writeSetterBody(JavaFileWriter writer, MethodDeclarationParameters params) throws IOException {
  String argName = params.getArgumentNames().get(0);
  final String argAsString = argName + "AsString";
  Expression condition = Expressions.fromString(argName + " == null");
  Expression ifTrue = Expressions.fromString("null");
  Expression ifFalse = Expressions.callMethodOn(argName, "name");
  writer.writeFieldDeclaration(CoreTypes.JAVA_STRING, argAsString,
      new TernaryExpression(condition, ifTrue, ifFalse));
  writer.writeStatement(Expressions.callMethod("set", propertyName, argAsString));
  writer.writeStringStatement("return this");
}
origin: com.yahoo.squidb/squidb-processor

private void emitSinglePropertyDeclaration(PropertyGenerator generator) throws IOException {
  modelSpec.getPluginBundle().beforeEmitPropertyDeclaration(writer, generator);
  writer.writeFieldDeclaration(generator.getPropertyType(), generator.getPropertyName(),
      Expressions.staticReference(modelSpec.getModelSpecName(), generator.getPropertyName()),
      TypeConstants.PUBLIC_STATIC_FINAL)
      .writeNewline();
  modelSpec.getPluginBundle().afterEmitPropertyDeclaration(writer, generator);
}
com.yahoo.aptutils.writerJavaFileWriterwriteFieldDeclaration

Popular methods of JavaFileWriter

  • writeStatement
  • writeStringStatement
  • appendExpression
  • appendString
  • beginConstructorDeclaration
  • beginInitializerBlock
  • beginMethodDefinition
  • beginTypeDefinition
  • close
  • finishInitializerBlock
  • finishMethodDefinition
  • finishScope
  • finishMethodDefinition,
  • finishScope,
  • finishTypeDefinition,
  • moveToScope,
  • registerOtherKnownNames,
  • shortenName,
  • writeAnnotation,
  • writeComment,
  • writeExpression

Popular in Java

  • Making http requests using okhttp
  • getExternalFilesDir (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getContentResolver (Context)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • JPanel (javax.swing)
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now