Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ String formatCaseStatement() {
kind = "bidiStreaming";
methodLambda = "typedReplies -> " + name + "(typedReplies, options)";
}

// spotless:off
return """
case $methodName -> Pipelines.<$requestType, $replyType>$kind()
.mapRequest(bytes -> parse$simpleRequestType(bytes, options))
Expand All @@ -225,9 +225,11 @@ String formatCaseStatement() {
.replace("$replyType", replyType)
.replace("$simpleReplyType", replyType.replace(".", ""))
.replace("$kind", kind);
// spotless:on
}

private String formatUnaryMethodImplementation() {
// spotless:off
return """
@Override
$methodSignatureWithoutOptions {
Expand Down Expand Up @@ -298,9 +300,11 @@ public void onComplete() {
.replace("$replyType", replyType)
.replace("$simpleReplyType", replyType.replace(".", ""))
.replace("$methodName", name);
// spotless:on
}

private String formatClientStreamingMethodImplementation() {
// spotless:off
return """
@Override
$methodSignatureWithoutOptions {
Expand Down Expand Up @@ -369,9 +373,11 @@ public void onComplete() {
.replace("$replyType", replyType)
.replace("$simpleReplyType", replyType.replace(".", ""))
.replace("$methodName", name);
// spotless:on
}

private String formatServerStreamingMethodImplementation() {
// spotless:off
return """
@Override
$methodSignatureWithoutOptions {
Expand Down Expand Up @@ -429,9 +435,11 @@ public void onComplete() {
.replace("$replyType", replyType)
.replace("$simpleReplyType", replyType.replace(".", ""))
.replace("$methodName", name);
// spotless:on
}

private String formatBidiStreamingMethodImplementation() {
// spotless:off
return """
@Override
$methodSignatureWithoutOptions {
Expand Down Expand Up @@ -496,6 +504,7 @@ public void onComplete() {
.replace("$replyType", replyType)
.replace("$simpleReplyType", replyType.replace(".", ""))
.replace("$methodName", name);
// spotless:on
}

String formatMethodImplementation() {
Expand Down Expand Up @@ -771,7 +780,7 @@ private static String formatParseRequestMethod(final String requestType) {
Objects.requireNonNull(options);

// not strict, no unknown fields, hard-code maxDepth for now, and use custom maxSize:
return get$simpleRequestTypeCodec(options).parse(message.toReadableSequentialData(), false, false, 16, options.maxMessageSizeBytes());
return get$simpleRequestTypeCodec(options).parse(message, false, false, 16, options.maxMessageSizeBytes());
}
"""
.replace("$requestType", requestType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class CodecFastEqualsMethodGenerator {

static String generateFastEqualsMethod(final String modelClassName, final List<Field> fields) {
// Placeholder implementation, replace faster implementation than full parse if there is one
// spotless:off
return """
/**
* Compares the given item with the bytes in the input, and returns false if it determines that
Expand All @@ -28,11 +29,12 @@ static String generateFastEqualsMethod(final String modelClassName, final List<F
* @return true if the bytes represent the item, false otherwise.
* @throws ParseException If parsing fails
*/
public boolean fastEquals(@NonNull $modelClass item, @NonNull final ReadableSequentialData input) throws ParseException {
public boolean fastEquals(@NonNull $modelClass item, @NonNull final PbjReader input) throws ParseException {
return item.equals(parse(input));
}
"""
.replace("$modelClass", modelClassName)
.indent(DEFAULT_INDENT);
// spotless:on
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CodecMeasureDataMethodGenerator {

static String generateMeasureMethod(final String modelClassName, final List<Field> fields) {
// Placeholder implementation, replace faster implementation than full parse if there is one
// spotless:off
return """
/**
* Reads from this data input the length of the data within the input. The implementation may
Expand All @@ -24,13 +25,14 @@ static String generateMeasureMethod(final String modelClassName, final List<Fiel
* @return The length of the data item in the input
* @throws ParseException If parsing fails
*/
public int measure(@NonNull final ReadableSequentialData input) throws ParseException {
public int measure(@NonNull final PbjReader input) throws ParseException {
final var start = input.position();
parse(input);
final var end = input.position();
return (int)(end - start);
}
"""
.indent(DEFAULT_INDENT);
// spotless:on
}
}
Loading
Loading