Search in sources :

Example 21 with TypeName

use of com.squareup.javapoet.TypeName in project raml-for-jax-rs by mulesoft-labs.

the class SchemaTypeFactory method createRamlToPojo.

public static TypeGenerator createRamlToPojo(CurrentBuild currentBuild, final V10GType type) {
    TypeName typeName = currentBuild.fetchRamlToPojoBuilder().fetchType(type.name(), type.implementation());
    RamlToPojoTypeGenerator gen = new RamlToPojoTypeGenerator(currentBuild.fetchRamlToPojoBuilder(), type.name(), type.implementation(), typeName);
    currentBuild.newGenerator(type.name(), gen);
    type.setJavaType(typeName);
    return gen;
}
Also used : TypeName(com.squareup.javapoet.TypeName) RamlToPojoTypeGenerator(org.raml.jaxrs.generator.builders.RamlToPojoTypeGenerator)

Example 22 with TypeName

use of com.squareup.javapoet.TypeName in project atlasdb by palantir.

the class TableFactoryRenderer method getSharedTriggers.

private TypeSpec getSharedTriggers() {
    TypeSpec.Builder sharedTriggersInterfaceBuilder = TypeSpec.interfaceBuilder("SharedTriggers").addModifiers(Modifier.PUBLIC);
    for (String name : definitions.keySet()) {
        String tableName = getTableName(name);
        String triggerName = tableName + "." + name + "Trigger";
        TypeName triggerType = ClassName.get(packageName, triggerName);
        sharedTriggersInterfaceBuilder.addSuperinterface(triggerType);
    }
    return sharedTriggersInterfaceBuilder.build();
}
Also used : WildcardTypeName(com.squareup.javapoet.WildcardTypeName) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName) TypeName(com.squareup.javapoet.TypeName) ArrayTypeName(com.squareup.javapoet.ArrayTypeName) TypeSpec(com.squareup.javapoet.TypeSpec)

Example 23 with TypeName

use of com.squareup.javapoet.TypeName in project atlasdb by palantir.

the class TableFactoryRenderer method getNullSharedTriggers.

private TypeSpec getNullSharedTriggers(TypeName sharedTriggersInterfaceType) {
    TypeSpec.Builder nullSharedTriggersClassBuilder = TypeSpec.classBuilder("NullSharedTriggers").addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT, Modifier.STATIC).addSuperinterface(sharedTriggersInterfaceType);
    for (Entry<String, TableDefinition> entry : definitions.entrySet()) {
        String name = entry.getKey();
        TableDefinition tableDefinition = entry.getValue();
        String tableName = getTableName(name);
        ClassName tableType = ClassName.get(packageName, tableName);
        TypeName rowType = tableType.nestedClass(name + "Row");
        TypeName columnType = tableType.nestedClass(name + "ColumnValue");
        if (!tableDefinition.toTableMetadata().getColumns().hasDynamicColumns()) {
            columnType = ParameterizedTypeName.get(ClassName.get(packageName, tableName + "." + name + "NamedColumnValue"), WildcardTypeName.subtypeOf(Object.class));
        }
        MethodSpec putMethod = MethodSpec.methodBuilder("put" + name).addAnnotation(Override.class).addModifiers(Modifier.PUBLIC).addParameter(ParameterizedTypeName.get(ClassName.get(Multimap.class), rowType, WildcardTypeName.subtypeOf(columnType)), "newRows").addComment("do nothing").build();
        nullSharedTriggersClassBuilder.addMethod(putMethod);
    }
    return nullSharedTriggersClassBuilder.build();
}
Also used : WildcardTypeName(com.squareup.javapoet.WildcardTypeName) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName) TypeName(com.squareup.javapoet.TypeName) ArrayTypeName(com.squareup.javapoet.ArrayTypeName) MethodSpec(com.squareup.javapoet.MethodSpec) ClassName(com.squareup.javapoet.ClassName) TableDefinition(com.palantir.atlasdb.table.description.TableDefinition) TypeSpec(com.squareup.javapoet.TypeSpec)

Example 24 with TypeName

use of com.squareup.javapoet.TypeName in project atlasdb by palantir.

the class TableFactoryRenderer method getTableMethod.

private MethodSpec getTableMethod(String name, TableDefinition tableDefinition) {
    String tableName = getTableName(name);
    String triggerName = tableName + "." + name + "Trigger";
    TypeName tableType = ClassName.get(packageName, tableName);
    TypeName triggerType = ClassName.get(packageName, triggerName);
    MethodSpec.Builder tableGetterMethodBuilder = MethodSpec.methodBuilder("get" + tableName).addModifiers(Modifier.PUBLIC).addParameter(Transaction.class, "t").returns(tableType);
    if (tableDefinition.getGenericTableName() != null) {
        tableGetterMethodBuilder.addParameter(String.class, "name").addParameter(ArrayTypeName.of(triggerType), "triggers").varargs().addStatement("return $T.of(t, namespace, name, $T.getAllTriggers(t, sharedTriggers, triggers))", tableType, Triggers.class);
    } else {
        tableGetterMethodBuilder.addParameter(ArrayTypeName.of(triggerType), "triggers").varargs().addStatement("return $T.of(t, namespace, $T.getAllTriggers(t, sharedTriggers, triggers))", tableType, Triggers.class);
    }
    return tableGetterMethodBuilder.build();
}
Also used : WildcardTypeName(com.squareup.javapoet.WildcardTypeName) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName) TypeName(com.squareup.javapoet.TypeName) ArrayTypeName(com.squareup.javapoet.ArrayTypeName) Transaction(com.palantir.atlasdb.transaction.api.Transaction) MethodSpec(com.squareup.javapoet.MethodSpec)

Example 25 with TypeName

use of com.squareup.javapoet.TypeName in project atlasdb by palantir.

the class TableClassRendererV2 method renderNamedPutColumn.

private MethodSpec renderNamedPutColumn(NamedColumnDescription col) {
    MethodSpec.Builder putColumnBuilder = MethodSpec.methodBuilder("put" + VarName(col)).addJavadoc("Takes the row-keys and a value to be inserted at column $L.", VarName(col)).addModifiers(Modifier.PUBLIC);
    putColumnBuilder = addParametersFromRowComponents(putColumnBuilder, tableMetadata);
    TypeName columnValueType = tableType.nestedClass(VarName(col));
    putColumnBuilder.addParameter(getColumnClass(col), col.getLongName());
    putColumnBuilder.addStatement("$T row = $T.of($L)", rowType, rowType, getArgumentsFromRowComponents(tableMetadata)).addStatement("t.put(tableRef, $T.toCellValues($T.of(row, $T.of($L))))", ColumnValues.class, ImmutableMultimap.class, columnValueType, col.getLongName());
    return putColumnBuilder.build();
}
Also used : TypeName(com.squareup.javapoet.TypeName) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName) MethodSpec(com.squareup.javapoet.MethodSpec)

Aggregations

TypeName (com.squareup.javapoet.TypeName)296 ParameterizedTypeName (com.squareup.javapoet.ParameterizedTypeName)232 MethodSpec (com.squareup.javapoet.MethodSpec)109 ClassName (com.squareup.javapoet.ClassName)82 WildcardTypeName (com.squareup.javapoet.WildcardTypeName)78 TypeSpec (com.squareup.javapoet.TypeSpec)55 ArrayTypeName (com.squareup.javapoet.ArrayTypeName)50 TypeElement (javax.lang.model.element.TypeElement)46 ArrayList (java.util.ArrayList)45 TypeMirror (javax.lang.model.type.TypeMirror)41 ExecutableElement (javax.lang.model.element.ExecutableElement)36 ParameterSpec (com.squareup.javapoet.ParameterSpec)26 Builder (com.squareup.javapoet.TypeSpec.Builder)22 SQLiteDaoDefinition (com.abubusoft.kripton.processor.sqlite.model.SQLiteDaoDefinition)21 CodeBlock (com.squareup.javapoet.CodeBlock)20 VariableElement (javax.lang.model.element.VariableElement)20 SQLiteEntity (com.abubusoft.kripton.processor.sqlite.model.SQLiteEntity)19 SQLProperty (com.abubusoft.kripton.processor.sqlite.model.SQLProperty)18 List (java.util.List)18 Map (java.util.Map)17