-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make service methods returning response type directly in cases when a…
… method is not output-streaming
- Loading branch information
Showing
8 changed files
with
121 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
generator/src/main/java/org/sudu/protogen/generator/type/VoidType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.sudu.protogen.generator.type; | ||
|
||
import com.squareup.javapoet.CodeBlock; | ||
import com.squareup.javapoet.TypeName; | ||
|
||
public class VoidType extends TypeModel { | ||
|
||
public VoidType() { | ||
super(TypeName.VOID); | ||
} | ||
|
||
@Override | ||
public CodeBlock toGrpcTransformer(CodeBlock expr) { | ||
return CodeBlock.of("null"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...ator/src/main/java/org/sudu/protogen/generator/type/processors/EmptyMessageProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.sudu.protogen.generator.type.processors; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.sudu.protogen.config.Configuration; | ||
import org.sudu.protogen.descriptors.EnumOrMessage; | ||
import org.sudu.protogen.descriptors.Message; | ||
import org.sudu.protogen.generator.type.TypeModel; | ||
import org.sudu.protogen.generator.type.VoidType; | ||
|
||
/** | ||
* Treats all empty messages as void | ||
*/ | ||
public class EmptyMessageProcessor extends TypeProcessor.Chain { | ||
|
||
@Override | ||
public @Nullable TypeModel processType(@NotNull EnumOrMessage descriptor, @NotNull Configuration configuration) { | ||
if (descriptor instanceof Message msg) { | ||
if (msg.getFields().isEmpty()) return new VoidType(); | ||
} | ||
return next(descriptor, configuration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters