.condition(equal(argument, constantNull(stackTypes.get(i)))) .ifTrue(blockBuilderVariable.invoke("appendNull", BlockBuilder.class).pop()) .ifFalse(constantType(binder, elementType).writeValue(blockBuilderVariable, argument.cast(elementType.getJavaType()))); body.append(ifStatement);
.condition(equal(fieldValue, constantNull(getter.getReturnType()))) .ifTrue(out.invoke("appendNull", BlockBuilder.class).pop()) .ifFalse(sqlType.writeValue(out, fieldValue))); serializerBody.append(sqlType.writeValue(out, fieldValue.cast(getOnlyElement(fields).getSqlType().getJavaType()))); serializerBody.append(new IfStatement().condition(equal(fieldValue, constantNull(getter.getReturnType()))) .ifTrue(rowBuilder.invoke("appendNull", BlockBuilder.class).pop()) .ifFalse(sqlType.writeValue(rowBuilder, fieldValue))); serializerBody.append(sqlType.writeValue(rowBuilder, fieldValue.cast(field.getSqlType().getJavaType())));
.ifFalse(constantType(binder, toTypes.get(i)).writeValue(singleRowBlockWriter, toElement));
.append(element.set(elementTypeConstant.getValue(array, position))) .append(newElement.set(mapper.apply(element))) .append(newElementTypeConstant.writeValue(blockBuilder, newElement)); mapperDescription = mapper.apply(element).toString();
.condition(context.wasNull()) .ifTrue(singleRowBlockWriter.invoke("appendNull", BlockBuilder.class).pop()) .ifFalse(constantType(binder, fieldType).writeValue(singleRowBlockWriter, field).pop()));
private void generateOutputMethod(ClassDefinition definition, CallSiteBinder binder, Type valueType, Class<?> stateClass) { Parameter state = arg("state", stateClass); Parameter out = arg("out", BlockBuilder.class); MethodDefinition method = definition.declareMethod(a(PUBLIC, STATIC), "output", type(void.class), state, out); IfStatement ifStatement = new IfStatement() .condition(or(state.invoke("isFirstNull", boolean.class), state.invoke("isSecondNull", boolean.class))) .ifTrue(new BytecodeBlock().append(out.invoke("appendNull", BlockBuilder.class)).pop()); SqlTypeBytecodeExpression valueSqlType = constantType(binder, valueType); BytecodeExpression getValueExpression; if (valueType.getJavaType().isPrimitive()) { getValueExpression = state.invoke("getSecond", valueType.getJavaType()); } else { getValueExpression = valueSqlType.getValue(state.invoke("getSecondBlock", Block.class), state.invoke("getSecondPosition", int.class)); } ifStatement.ifFalse(valueSqlType.writeValue(out, getValueExpression)); method.getBody().append(ifStatement).ret(); } }
.condition(equal(outputElement, constantNull(outputJavaType))) .ifTrue(blockBuilder.invoke("appendNull", BlockBuilder.class).pop()) .ifFalse(constantType(binder, outputType).writeValue(blockBuilder, outputElement.cast(outputType.getJavaType())));
.condition(equal(transformedValueElement, constantNull(transformedValueJavaType))) .ifTrue(blockBuilder.invoke("appendNull", BlockBuilder.class).pop()) .ifFalse(constantType(binder, transformedValueType).writeValue(blockBuilder, transformedValueElement.cast(transformedValueType.getJavaType())));
.ifTrue(throwNullKeyException) .ifFalse(new BytecodeBlock() .append(constantType(binder, transformedKeyType).writeValue(blockBuilder, transformedKeyElement.cast(transformedKeyType.getJavaType()))) .append(valueSqlType.invoke("appendTo", void.class, block, add(position, constantInt(1)), blockBuilder))));
.condition(equal(argument, constantNull(stackTypes.get(i)))) .ifTrue(blockBuilderVariable.invoke("appendNull", BlockBuilder.class).pop()) .ifFalse(constantType(binder, elementType).writeValue(blockBuilderVariable, argument.cast(elementType.getJavaType()))); body.append(ifStatement);
.append(element.set(elementTypeConstant.getValue(array, position))) .append(newElement.set(mapper.apply(element))) .append(newElementTypeConstant.writeValue(blockBuilder, newElement)); mapperDescription = mapper.apply(element).toString();