-
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.
Add an ability to pick a container for streaming a method
- Loading branch information
Showing
11 changed files
with
61 additions
and
54 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
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
36 changes: 36 additions & 0 deletions
36
generator/src/main/java/org/sudu/protogen/protobuf/RepeatedContainer.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,36 @@ | ||
package org.sudu.protogen.protobuf; | ||
|
||
import com.squareup.javapoet.ClassName; | ||
import com.squareup.javapoet.CodeBlock; | ||
import protogen.Options; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
public enum RepeatedContainer { | ||
LIST(ClassName.get("java.util", "List"), CodeBlock.of("$T.toList()", Collectors.class)), | ||
SET(ClassName.get("java.util", "Set"), CodeBlock.of("$T.toSet()", Collectors.class)); | ||
|
||
private final ClassName typeName; | ||
private final CodeBlock collectorExpr; | ||
|
||
RepeatedContainer(ClassName typeName, CodeBlock collectorExpr) { | ||
this.typeName = typeName; | ||
this.collectorExpr = collectorExpr; | ||
} | ||
|
||
public static RepeatedContainer fromGrpc(Options.RepeatedContainer proto) { | ||
return switch (proto) { | ||
case UNRECOGNIZED -> throw new IllegalArgumentException(); | ||
case LIST -> RepeatedContainer.LIST; | ||
case SET -> RepeatedContainer.SET; | ||
}; | ||
} | ||
|
||
public ClassName getTypeName() { | ||
return typeName; | ||
} | ||
|
||
public CodeBlock getCollectorExpr() { | ||
return collectorExpr; | ||
} | ||
} |
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