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;
}
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();
}
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();
}
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();
}
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();
}
Aggregations