-
Notifications
You must be signed in to change notification settings - Fork 108
Update templates #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Update templates #362
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -1,35 +1,87 @@ | ||
#set( $WorkflowName = "${NAME}Workflow" ) | ||
package ${PACKAGE_NAME} | ||
#set ($prefix = $NAME.replace('Workflow', '') ) | ||
## build props string | ||
#if( $PROPS_TYPE_OPTIONAL == '') | ||
#set ($props_type = $prefix + "Props") | ||
#else | ||
#set ($props_type = $PROPS_TYPE_OPTIONAL) | ||
#end | ||
## build state string | ||
#if( $STATE_TYPE_OPTIONAL == '') | ||
#set ($state_type = $prefix + "State") | ||
#else | ||
#set ($state_type = $STATE_TYPE_OPTIONAL) | ||
#end | ||
## build output string | ||
#if( $OUTPUT_TYPE_OPTIONAL == '') | ||
#set ($output_type = $prefix + "Output") | ||
#else | ||
#set ($output_type = $OUTPUT_TYPE_OPTIONAL) | ||
#end | ||
## build rendering string | ||
#if( $RENDERING_TYPE_OPTIONAL == '') | ||
#set ($rendering_type = $prefix + "Rendering") | ||
#else | ||
#set ($rendering_type = $RENDERING_TYPE_OPTIONAL) | ||
#end | ||
package $PACKAGE_NAME | ||
|
||
import com.squareup.workflow1.Snapshot | ||
import com.squareup.workflow1.StatefulWorkflow | ||
import ${PACKAGE_NAME}.${WorkflowName}.Output | ||
import ${PACKAGE_NAME}.${WorkflowName}.Props | ||
import ${PACKAGE_NAME}.${WorkflowName}.Rendering | ||
import ${PACKAGE_NAME}.${WorkflowName}.State | ||
|
||
#if( $PROPS_TYPE_OPTIONAL == '') ## import if we create below | ||
import $PACKAGE_NAME.$NAME.$props_type | ||
#end | ||
#if( $STATE_TYPE_OPTIONAL == '') ## import if we create below | ||
import $PACKAGE_NAME.$NAME.$state_type | ||
#end | ||
#if( $OUTPUT_TYPE_OPTIONAL == '') ## import if we create below | ||
import $PACKAGE_NAME.$NAME.$output_type | ||
#end | ||
#if( $RENDERING_TYPE_OPTIONAL == '') ## import if we create below | ||
import $PACKAGE_NAME.$NAME.$rendering_type | ||
#end | ||
|
||
#parse("File Header.java") | ||
class ${WorkflowName} : StatefulWorkflow<Props, State, Output, Rendering>() { | ||
object $NAME : StatefulWorkflow<$props_type, $state_type, $output_type, $rendering_type>() { | ||
|
||
data class Props | ||
data class State | ||
data class Output | ||
data class Rendering | ||
#if( $PROPS_TYPE_OPTIONAL == '') ## create if not supplied | ||
data class $props_type( | ||
// TODO add args | ||
) | ||
#end | ||
|
||
#if( $STATE_TYPE_OPTIONAL == '') ## create if not supplied | ||
data class $state_type( | ||
// TODO add args | ||
) | ||
#end | ||
|
||
#if( $OUTPUT_TYPE_OPTIONAL == '') ## create if not supplied | ||
data class $output_type( | ||
// TODO add args | ||
) | ||
#end | ||
|
||
#if( $RENDERING_TYPE_OPTIONAL == '') ## create if not supplied | ||
data class $rendering_type( | ||
// TODO add args | ||
) | ||
#end | ||
|
||
override fun initialState( | ||
props: Props, | ||
props: $props_type, | ||
snapshot: Snapshot? | ||
): State = TODO("Initialize state") | ||
): $state_type = TODO("Initialize state") | ||
|
||
override fun render( | ||
renderProps: Props, | ||
renderState: State, | ||
props: $props_type, | ||
state: $state_type, | ||
context: RenderContext | ||
): Rendering { | ||
): $rendering_type { | ||
TODO("Render") | ||
} | ||
|
||
override fun snapshotState(state: State): Snapshot? = Snapshot.write { | ||
override fun snapshotState(state: $state_type): Snapshot? = Snapshot.write { | ||
TODO("Save state") | ||
} | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -1,22 +1,61 @@ | ||
#set( $WorkflowName = "${NAME}Workflow" ) | ||
package ${PACKAGE_NAME} | ||
#set ($prefix = $NAME.replace('Workflow', '') ) | ||
## build props string | ||
#if( $PROPS_TYPE_OPTIONAL == '') | ||
#set ($props_type = $prefix + "Props") | ||
#else | ||
#set ($props_type = $PROPS_TYPE_OPTIONAL) | ||
#end | ||
## build output string | ||
#if( $OUTPUT_TYPE_OPTIONAL == '') | ||
#set ($output_type = $prefix + "Output") | ||
#else | ||
#set ($output_type = $OUTPUT_TYPE_OPTIONAL) | ||
#end | ||
## build rendering string | ||
#if( $RENDERING_TYPE_OPTIONAL == '') | ||
#set ($rendering_type = $prefix + "Rendering") | ||
#else | ||
#set ($rendering_type = $RENDERING_TYPE_OPTIONAL) | ||
#end | ||
package $PACKAGE_NAME | ||
|
||
import com.squareup.workflow1.StatelessWorkflow | ||
import ${PACKAGE_NAME}.${WorkflowName}.Output | ||
import ${PACKAGE_NAME}.${WorkflowName}.Props | ||
import ${PACKAGE_NAME}.${WorkflowName}.Rendering | ||
|
||
#if( $PROPS_TYPE_OPTIONAL == '') ## import if we create below | ||
import $PACKAGE_NAME.$NAME.$props_type | ||
#end | ||
#if( $OUTPUT_TYPE_OPTIONAL == '') ## import if we create below | ||
import $PACKAGE_NAME.$NAME.$output_type | ||
#end | ||
#if( $RENDERING_TYPE_OPTIONAL == '') ## import if we create below | ||
import $PACKAGE_NAME.$NAME.$rendering_type | ||
#end | ||
|
||
#parse("File Header.java") | ||
class ${WorkflowName} : StatelessWorkflow<Props, Output, Rendering>() { | ||
object $NAME : StatelessWorkflow<$props_type, $output_type, $rendering_type>() { | ||
|
||
#if( $PROPS_TYPE_OPTIONAL == '') ## create if not supplied | ||
data class $props_type( | ||
// TODO add args | ||
) | ||
#end | ||
|
||
data class Props | ||
data class Output | ||
data class Rendering | ||
#if( $OUTPUT_TYPE_OPTIONAL == '') ## create if not supplied | ||
data class $output_type( | ||
// TODO add args | ||
) | ||
#end | ||
|
||
#if( $RENDERING_TYPE_OPTIONAL == '') ## create if not supplied | ||
data class $rendering_type( | ||
// TODO add args | ||
) | ||
#end | ||
|
||
override fun render( | ||
renderProps: Props, | ||
props: $props_type, | ||
context: RenderContext | ||
): Rendering { | ||
): $rendering_type { | ||
TODO("Render") | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the part where it gets trickier as suggesting this pattern of internal data classes is a goal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how complex you want it to get, but there could be an option to leave the template blank for at type and then these would be generated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool. Didn't know about the internal pattern. I'll experiment with an if --> auto generate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok @steve-the-edwards I think I have it working. If you leave an "optional" field blank then it will auto generate inner class (and import)