未验证 提交 96bdde74 编写于 作者: A Andrei Bocan 提交者: GitHub

Kotlin: Add option to add defaults to nullable fields (#863)

上级 69dee51d
......@@ -56,6 +56,7 @@ See [DirectiveAnnotationsMapping](#option-directiveannotationsmapping)* |
| `responseProjectionMaxDepth` | Integer | 3 | Sets max depth when use `all$()` which for facilitating the construction of projection automatically, the fields on all projections are provided when it be invoked. This is a global configuration, of course, you can use `all$(max)` to set for each method. For self recursive types, too big depth may result in a large number of returned data!|
| `generatedLanguage` | Enum | GeneratedLanguage.JAVA | Choose which language you want to generate, Java,Scala,Kotlin were supported. Note that due to language features, there are slight differences in default values between languages.|
| `generateModelOpenClasses` | Boolean | false | The class type of the generated model. If true, generate normal classes, else generate data classes. It only support in kotlin(```data class```) and scala(```case class```). Maybe we will consider to support Java ```record``` in the future.|
| `initializeNullableTypes` | Boolean | false | Adds a default null value to nullable arguments. Only supported in Kotlin.
| `typesAsInterfaces` | Set(String) | Empty | Types that must generated as interfaces should be defined here in format: `TypeName` or `@directive`. E.g.: `User`, `@asInterface`. |
### Option `graphqlSchemas`
......
......@@ -103,6 +103,7 @@ public class GraphQLCodegenGradleTask extends DefaultTask implements GraphQLCode
private List<String> configurationFiles;
private GeneratedLanguage generatedLanguage = MappingConfigConstants.DEFAULT_GENERATED_LANGUAGE;
private Boolean generateModelOpenClasses = MappingConfigConstants.DEFAULT_GENERATE_MODEL_OPEN_CLASSES;
private Boolean initializeNullableTypes = MappingConfigConstants.DEFAULT_INITIALIZE_NULLABLE_TYPES;
public GraphQLCodegenGradleTask() {
setGroup("codegen");
......@@ -178,6 +179,7 @@ public class GraphQLCodegenGradleTask extends DefaultTask implements GraphQLCode
mappingConfig.setGeneratedLanguage(generatedLanguage);
mappingConfig.setGenerateModelOpenClasses(generateModelOpenClasses);
mappingConfig.setInitializeNullableTypes(initializeNullableTypes);
instantiateCodegen(mappingConfig).generate();
}
......@@ -844,4 +846,15 @@ public class GraphQLCodegenGradleTask extends DefaultTask implements GraphQLCode
public void setGenerateModelOpenClasses(Boolean generateModelOpenClasses) {
this.generateModelOpenClasses = generateModelOpenClasses;
}
@Input
@Optional
@Override
public Boolean isInitializeNullableTypes() {
return initializeNullableTypes;
}
public void setInitializeNullableTypes(Boolean initializeNullableTypes) {
this.initializeNullableTypes = initializeNullableTypes;
}
}
......@@ -209,6 +209,9 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
@Parameter(defaultValue = MappingConfigConstants.DEFAULT_GENERATE_MODEL_OPEN_CLASSES_STRING)
private boolean generateModelOpenClasses;
@Parameter(defaultValue = MappingConfigConstants.DEFAULT_INITIALIZE_NULLABLE_TYPES_STRING)
private boolean initializeNullableTypes;
@Override
public void execute() throws MojoExecutionException {
addCompileSourceRootIfConfigured();
......@@ -267,6 +270,7 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
mappingConfig.setGeneratedLanguage(generatedLanguage);
mappingConfig.setGenerateModelOpenClasses(isGenerateModelOpenClasses());
mappingConfig.setInitializeNullableTypes(isInitializeNullableTypes());
try {
instantiateCodegen(mappingConfig).generate();
......@@ -603,6 +607,11 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
return generateModelOpenClasses;
}
@Override
public Boolean isInitializeNullableTypes() {
return initializeNullableTypes;
}
public ParentInterfacesConfig getParentInterfaces() {
return parentInterfaces;
}
......
......@@ -49,6 +49,9 @@ public class KotlinGraphQLCodegen extends GraphQLCodegen {
if (mappingConfig.isGenerateModelOpenClasses() == null) {
mappingConfig.setGenerateModelOpenClasses(false);
}
if (mappingConfig.isInitializeNullableTypes() == null) {
mappingConfig.setInitializeNullableTypes(false);
}
if (mappingConfig.getGenerateBuilder() == null) {
// functional expression
mappingConfig.setGenerateBuilder(false);
......
......@@ -24,6 +24,7 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static com.kobylynskyi.graphql.codegen.model.DataModelFields.INITIALIZE_NULLABLE_TYPES;
import static com.kobylynskyi.graphql.codegen.model.DataModelFields.CLASS_NAME;
import static com.kobylynskyi.graphql.codegen.model.DataModelFields.ENUM_IMPORT_IT_SELF_IN_SCALA;
import static com.kobylynskyi.graphql.codegen.model.DataModelFields.GENERATED_ANNOTATION;
......@@ -162,6 +163,7 @@ public class FieldDefinitionsToResolverDataModelMapper {
dataModel.put(GENERATED_INFO, mappingContext.getGeneratedInformation());
dataModel.put(ENUM_IMPORT_IT_SELF_IN_SCALA, mappingContext.getEnumImportItSelfInScala());
dataModel.put(GENERATE_MODEL_OPEN_CLASSES, mappingContext.isGenerateModelOpenClasses());
dataModel.put(INITIALIZE_NULLABLE_TYPES, mappingContext.isInitializeNullableTypes());
return dataModel;
}
......
......@@ -8,6 +8,7 @@ import java.util.HashMap;
import java.util.Map;
import static com.kobylynskyi.graphql.codegen.model.DataModelFields.ANNOTATIONS;
import static com.kobylynskyi.graphql.codegen.model.DataModelFields.INITIALIZE_NULLABLE_TYPES;
import static com.kobylynskyi.graphql.codegen.model.DataModelFields.BUILDER;
import static com.kobylynskyi.graphql.codegen.model.DataModelFields.CLASS_NAME;
import static com.kobylynskyi.graphql.codegen.model.DataModelFields.ENUM_IMPORT_IT_SELF_IN_SCALA;
......@@ -67,6 +68,7 @@ public class InputDefinitionToDataModelMapper {
dataModel.put(GENERATED_INFO, mappingContext.getGeneratedInformation());
dataModel.put(ENUM_IMPORT_IT_SELF_IN_SCALA, mappingContext.getEnumImportItSelfInScala());
dataModel.put(GENERATE_MODEL_OPEN_CLASSES, mappingContext.isGenerateModelOpenClasses());
dataModel.put(INITIALIZE_NULLABLE_TYPES, mappingContext.isInitializeNullableTypes());
return dataModel;
}
......
......@@ -18,6 +18,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import static com.kobylynskyi.graphql.codegen.model.DataModelFields.ANNOTATIONS;
import static com.kobylynskyi.graphql.codegen.model.DataModelFields.INITIALIZE_NULLABLE_TYPES;
import static com.kobylynskyi.graphql.codegen.model.DataModelFields.BUILDER;
import static com.kobylynskyi.graphql.codegen.model.DataModelFields.CLASS_NAME;
import static com.kobylynskyi.graphql.codegen.model.DataModelFields.ENUM_IMPORT_IT_SELF_IN_SCALA;
......@@ -102,6 +103,7 @@ public class TypeDefinitionToDataModelMapper {
dataModel.put(ENUM_IMPORT_IT_SELF_IN_SCALA, mappingContext.getEnumImportItSelfInScala());
dataModel.put(PARENT_INTERFACE_PROPERTIES, mappingContext.getParentInterfaceProperties());
dataModel.put(GENERATE_MODEL_OPEN_CLASSES, mappingContext.isGenerateModelOpenClasses());
dataModel.put(INITIALIZE_NULLABLE_TYPES, mappingContext.isInitializeNullableTypes());
return dataModel;
}
......
......@@ -36,6 +36,7 @@ public final class DataModelFields {
public static final String PARENT_INTERFACE_PROPERTIES = "parentInterfaceProperties";
public static final String SERIALIZATION_LIBRARY = "serializationLibrary";
public static final String GENERATE_MODEL_OPEN_CLASSES = "generateModelOpenClasses";
public static final String INITIALIZE_NULLABLE_TYPES = "initializeNullableTypes";
private DataModelFields() {
}
......
......@@ -446,4 +446,12 @@ public interface GraphQLCodegenConfiguration {
*/
Boolean isGenerateModelOpenClasses();
/**
* Specifies whether classes should be generated with constructors setting the
* default value for nullable fields to null.
*
* @return <b>true</b> if nullable fields should be defaulted to null.
*/
Boolean isInitializeNullableTypes();
}
......@@ -78,6 +78,7 @@ public class MappingConfig implements GraphQLCodegenConfiguration, Combinable<Ma
private Set<String> typesAsInterfaces = new HashSet<>();
private boolean generateModelOpenClasses;
private boolean initializeNullableTypes;
private GeneratedLanguage generatedLanguage;
......@@ -185,6 +186,8 @@ public class MappingConfig implements GraphQLCodegenConfiguration, Combinable<Ma
generatedLanguage = getValueOrDefaultToThis(source, GraphQLCodegenConfiguration::getGeneratedLanguage);
generateModelOpenClasses = getValueOrDefaultToThis(source,
GraphQLCodegenConfiguration::isGenerateModelOpenClasses);
initializeNullableTypes = getValueOrDefaultToThis(source,
GraphQLCodegenConfiguration::isInitializeNullableTypes);
}
private <T> T getValueOrDefaultToThis(MappingConfig source, Function<MappingConfig, T> getValueFunction) {
......@@ -647,7 +650,6 @@ public class MappingConfig implements GraphQLCodegenConfiguration, Combinable<Ma
this.generatedLanguage = generatedLanguage;
}
public Boolean isGenerateModelOpenClasses() {
return generateModelOpenClasses;
}
......@@ -656,4 +658,12 @@ public class MappingConfig implements GraphQLCodegenConfiguration, Combinable<Ma
this.generateModelOpenClasses = generateModelOpenClasses;
}
public Boolean isInitializeNullableTypes() {
return initializeNullableTypes;
}
public void setInitializeNullableTypes(boolean initializeNullableTypes) {
this.initializeNullableTypes = initializeNullableTypes;
}
}
......@@ -68,6 +68,10 @@ public class MappingConfigConstants {
public static final boolean DEFAULT_GENERATE_MODEL_OPEN_CLASSES = false;
public static final String DEFAULT_GENERATE_MODEL_OPEN_CLASSES_STRING = "false";
//Only supported in kotlin.
public static final boolean DEFAULT_INITIALIZE_NULLABLE_TYPES = false;
public static final String DEFAULT_INITIALIZE_NULLABLE_TYPES_STRING = "false";
private MappingConfigConstants() {
}
......
......@@ -57,6 +57,11 @@ public class MappingContext implements GraphQLCodegenConfiguration {
return config.isGenerateModelOpenClasses();
}
@Override
public Boolean isInitializeNullableTypes() {
return config.isInitializeNullableTypes();
}
@Override
public Map<String, String> getCustomTypesMapping() {
return config.getCustomTypesMapping();
......
......@@ -68,7 +68,7 @@ open class ${className}()<#if implements?has_content> : <#list implements as int
<#if parentInterfaces?has_content><#list parentInterfaces as parent><#if parent == field.name>override
</#if></#list></#if><#if !immutableModels><#list field.annotations as annotation>@get:${annotation}
</#list>var <#else><#list field.annotations as annotation>@get:${annotation}
</#list>val </#if>${field.name}: ${field.type}<#if field.defaultValue?has_content> = ${field.defaultValue}</#if><#if field_has_next>,</#if>
</#list>val </#if>${field.name}: ${field.type}<#if field.defaultValue?has_content> = ${field.defaultValue}<#elseif field.type?ends_with("?") && (initializeNullableTypes == true)> = null</#if><#if field_has_next>,</#if>
</#list>
</#if>
)<#if implements?has_content> : <#list implements as interface>${interface}<#if interface_has_next>, </#if></#list></#if> {
......
package com.kobylynskyi.graphql.codegen.kotlin;
import com.kobylynskyi.graphql.codegen.TestUtils;
import com.kobylynskyi.graphql.codegen.model.GeneratedLanguage;
import com.kobylynskyi.graphql.codegen.model.MappingConfig;
import com.kobylynskyi.graphql.codegen.utils.Utils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.Objects;
import static com.kobylynskyi.graphql.codegen.TestUtils.assertSameTrimmedContent;
import static com.kobylynskyi.graphql.codegen.TestUtils.getFileByName;
import static java.util.Collections.singletonList;
class GraphQLCodegenInitializeNullableTypesTest {
private final File outputBuildDir = new File("build/generated");
private final File outputScalaClassesDir = new File("build/generated/com/github/graphql");
private final MappingConfig mappingConfig = new MappingConfig();
@BeforeEach
void init() {
mappingConfig.setGenerateParameterizedFieldsResolvers(false);
mappingConfig.setPackageName("com.github.graphql");
mappingConfig.setGeneratedLanguage(GeneratedLanguage.KOTLIN);
mappingConfig.setGenerateToString(true);
mappingConfig.setGenerateApis(true);
mappingConfig.setGenerateClient(true);
mappingConfig.setGenerateEqualsAndHashCode(true);
mappingConfig.setInitializeNullableTypes(true);
mappingConfig.setGenerateBuilder(true);
}
@AfterEach
void cleanup() {
Utils.deleteDir(outputBuildDir);
}
@Test
void generate_InitializeNullableTypes() throws Exception {
new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
File[] files = Objects.requireNonNull(outputScalaClassesDir.listFiles());
assertSameTrimmedContent(
new File("src/test/resources/expected-classes/kt/Commit_initialize_nullable_types.kt.txt"),
getFileByName(files, "Commit.kt"));
}
}
package com.github.graphql
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLRequestSerializer
import java.util.StringJoiner
@javax.annotation.Generated(
value = ["com.kobylynskyi.graphql.codegen.GraphQLCodegen"],
date = "2020-12-31T23:59:59-0500"
)
data class Commit(
override
val abbreviatedOid: String,
val additions: Int,
val associatedPullRequests: PullRequestConnection? = null,
val author: GitActor? = null,
val authoredByCommitter: Boolean,
val authoredDate: String,
val blame: Blame,
val changedFiles: Int,
val comments: CommitCommentConnection,
override
val commitResourcePath: String,
override
val commitUrl: String,
val committedDate: String,
val committedViaWeb: Boolean,
val committer: GitActor? = null,
val deletions: Int,
val deployments: DeploymentConnection? = null,
val history: CommitHistoryConnection,
override
val id: String,
val message: String,
val messageBody: String,
val messageBodyHTML: String,
val messageHeadline: String,
val messageHeadlineHTML: String,
override
val oid: String,
val parents: CommitConnection,
val pushedDate: String? = null,
override
val repository: Repository,
override
val resourcePath: String,
val signature: GitSignature? = null,
val status: Status? = null,
val tarballUrl: String,
val tree: Tree,
val treeResourcePath: String,
val treeUrl: String,
override
val url: String,
override
val viewerCanSubscribe: Boolean,
override
val viewerSubscription: SubscriptionState? = null,
val zipballUrl: String
) : Closer, IssueTimelineItem, PullRequestTimelineItem, Subscribable, Node, GitObject, UniformResourceLocatable {
companion object {
@JvmStatic fun builder(): Builder = Builder()
}
// In the future, it maybe change.
override fun toString(): String {
val joiner = StringJoiner(", ", "{ ", " }")
joiner.add("abbreviatedOid: " + GraphQLRequestSerializer.getEntry(abbreviatedOid))
joiner.add("additions: " + GraphQLRequestSerializer.getEntry(additions))
if (associatedPullRequests != null) {
joiner.add("associatedPullRequests: " + GraphQLRequestSerializer.getEntry(associatedPullRequests))
}
if (author != null) {
joiner.add("author: " + GraphQLRequestSerializer.getEntry(author))
}
joiner.add("authoredByCommitter: " + GraphQLRequestSerializer.getEntry(authoredByCommitter))
joiner.add("authoredDate: " + GraphQLRequestSerializer.getEntry(authoredDate))
joiner.add("blame: " + GraphQLRequestSerializer.getEntry(blame))
joiner.add("changedFiles: " + GraphQLRequestSerializer.getEntry(changedFiles))
joiner.add("comments: " + GraphQLRequestSerializer.getEntry(comments))
joiner.add("commitResourcePath: " + GraphQLRequestSerializer.getEntry(commitResourcePath))
joiner.add("commitUrl: " + GraphQLRequestSerializer.getEntry(commitUrl))
joiner.add("committedDate: " + GraphQLRequestSerializer.getEntry(committedDate))
joiner.add("committedViaWeb: " + GraphQLRequestSerializer.getEntry(committedViaWeb))
if (committer != null) {
joiner.add("committer: " + GraphQLRequestSerializer.getEntry(committer))
}
joiner.add("deletions: " + GraphQLRequestSerializer.getEntry(deletions))
if (deployments != null) {
joiner.add("deployments: " + GraphQLRequestSerializer.getEntry(deployments))
}
joiner.add("history: " + GraphQLRequestSerializer.getEntry(history))
joiner.add("id: " + GraphQLRequestSerializer.getEntry(id))
joiner.add("message: " + GraphQLRequestSerializer.getEntry(message))
joiner.add("messageBody: " + GraphQLRequestSerializer.getEntry(messageBody))
joiner.add("messageBodyHTML: " + GraphQLRequestSerializer.getEntry(messageBodyHTML))
joiner.add("messageHeadline: " + GraphQLRequestSerializer.getEntry(messageHeadline))
joiner.add("messageHeadlineHTML: " + GraphQLRequestSerializer.getEntry(messageHeadlineHTML))
joiner.add("oid: " + GraphQLRequestSerializer.getEntry(oid))
joiner.add("parents: " + GraphQLRequestSerializer.getEntry(parents))
if (pushedDate != null) {
joiner.add("pushedDate: " + GraphQLRequestSerializer.getEntry(pushedDate))
}
joiner.add("repository: " + GraphQLRequestSerializer.getEntry(repository))
joiner.add("resourcePath: " + GraphQLRequestSerializer.getEntry(resourcePath))
if (signature != null) {
joiner.add("signature: " + GraphQLRequestSerializer.getEntry(signature))
}
if (status != null) {
joiner.add("status: " + GraphQLRequestSerializer.getEntry(status))
}
joiner.add("tarballUrl: " + GraphQLRequestSerializer.getEntry(tarballUrl))
joiner.add("tree: " + GraphQLRequestSerializer.getEntry(tree))
joiner.add("treeResourcePath: " + GraphQLRequestSerializer.getEntry(treeResourcePath))
joiner.add("treeUrl: " + GraphQLRequestSerializer.getEntry(treeUrl))
joiner.add("url: " + GraphQLRequestSerializer.getEntry(url))
joiner.add("viewerCanSubscribe: " + GraphQLRequestSerializer.getEntry(viewerCanSubscribe))
if (viewerSubscription != null) {
joiner.add("viewerSubscription: " + GraphQLRequestSerializer.getEntry(viewerSubscription))
}
joiner.add("zipballUrl: " + GraphQLRequestSerializer.getEntry(zipballUrl))
return joiner.toString()
}
class Builder {
private lateinit var abbreviatedOid: String
private var additions: Int = 0
private var associatedPullRequests: PullRequestConnection? = null
private var author: GitActor? = null
private var authoredByCommitter: Boolean = false
private lateinit var authoredDate: String
private lateinit var blame: Blame
private var changedFiles: Int = 0
private lateinit var comments: CommitCommentConnection
private lateinit var commitResourcePath: String
private lateinit var commitUrl: String
private lateinit var committedDate: String
private var committedViaWeb: Boolean = false
private var committer: GitActor? = null
private var deletions: Int = 0
private var deployments: DeploymentConnection? = null
private lateinit var history: CommitHistoryConnection
private lateinit var id: String
private lateinit var message: String
private lateinit var messageBody: String
private lateinit var messageBodyHTML: String
private lateinit var messageHeadline: String
private lateinit var messageHeadlineHTML: String
private lateinit var oid: String
private lateinit var parents: CommitConnection
private var pushedDate: String? = null
private lateinit var repository: Repository
private lateinit var resourcePath: String
private var signature: GitSignature? = null
private var status: Status? = null
private lateinit var tarballUrl: String
private lateinit var tree: Tree
private lateinit var treeResourcePath: String
private lateinit var treeUrl: String
private lateinit var url: String
private var viewerCanSubscribe: Boolean = false
private var viewerSubscription: SubscriptionState? = null
private lateinit var zipballUrl: String
fun setAbbreviatedOid(abbreviatedOid: String): Builder {
this.abbreviatedOid = abbreviatedOid
return this
}
fun setAdditions(additions: Int): Builder {
this.additions = additions
return this
}
fun setAssociatedPullRequests(associatedPullRequests: PullRequestConnection?): Builder {
this.associatedPullRequests = associatedPullRequests
return this
}
fun setAuthor(author: GitActor?): Builder {
this.author = author
return this
}
fun setAuthoredByCommitter(authoredByCommitter: Boolean): Builder {
this.authoredByCommitter = authoredByCommitter
return this
}
fun setAuthoredDate(authoredDate: String): Builder {
this.authoredDate = authoredDate
return this
}
fun setBlame(blame: Blame): Builder {
this.blame = blame
return this
}
fun setChangedFiles(changedFiles: Int): Builder {
this.changedFiles = changedFiles
return this
}
fun setComments(comments: CommitCommentConnection): Builder {
this.comments = comments
return this
}
fun setCommitResourcePath(commitResourcePath: String): Builder {
this.commitResourcePath = commitResourcePath
return this
}
fun setCommitUrl(commitUrl: String): Builder {
this.commitUrl = commitUrl
return this
}
fun setCommittedDate(committedDate: String): Builder {
this.committedDate = committedDate
return this
}
fun setCommittedViaWeb(committedViaWeb: Boolean): Builder {
this.committedViaWeb = committedViaWeb
return this
}
fun setCommitter(committer: GitActor?): Builder {
this.committer = committer
return this
}
fun setDeletions(deletions: Int): Builder {
this.deletions = deletions
return this
}
fun setDeployments(deployments: DeploymentConnection?): Builder {
this.deployments = deployments
return this
}
fun setHistory(history: CommitHistoryConnection): Builder {
this.history = history
return this
}
fun setId(id: String): Builder {
this.id = id
return this
}
fun setMessage(message: String): Builder {
this.message = message
return this
}
fun setMessageBody(messageBody: String): Builder {
this.messageBody = messageBody
return this
}
fun setMessageBodyHTML(messageBodyHTML: String): Builder {
this.messageBodyHTML = messageBodyHTML
return this
}
fun setMessageHeadline(messageHeadline: String): Builder {
this.messageHeadline = messageHeadline
return this
}
fun setMessageHeadlineHTML(messageHeadlineHTML: String): Builder {
this.messageHeadlineHTML = messageHeadlineHTML
return this
}
fun setOid(oid: String): Builder {
this.oid = oid
return this
}
fun setParents(parents: CommitConnection): Builder {
this.parents = parents
return this
}
fun setPushedDate(pushedDate: String?): Builder {
this.pushedDate = pushedDate
return this
}
fun setRepository(repository: Repository): Builder {
this.repository = repository
return this
}
fun setResourcePath(resourcePath: String): Builder {
this.resourcePath = resourcePath
return this
}
fun setSignature(signature: GitSignature?): Builder {
this.signature = signature
return this
}
fun setStatus(status: Status?): Builder {
this.status = status
return this
}
fun setTarballUrl(tarballUrl: String): Builder {
this.tarballUrl = tarballUrl
return this
}
fun setTree(tree: Tree): Builder {
this.tree = tree
return this
}
fun setTreeResourcePath(treeResourcePath: String): Builder {
this.treeResourcePath = treeResourcePath
return this
}
fun setTreeUrl(treeUrl: String): Builder {
this.treeUrl = treeUrl
return this
}
fun setUrl(url: String): Builder {
this.url = url
return this
}
fun setViewerCanSubscribe(viewerCanSubscribe: Boolean): Builder {
this.viewerCanSubscribe = viewerCanSubscribe
return this
}
fun setViewerSubscription(viewerSubscription: SubscriptionState?): Builder {
this.viewerSubscription = viewerSubscription
return this
}
fun setZipballUrl(zipballUrl: String): Builder {
this.zipballUrl = zipballUrl
return this
}
fun build(): Commit {
return Commit(abbreviatedOid, additions, associatedPullRequests, author, authoredByCommitter, authoredDate, blame, changedFiles, comments, commitResourcePath, commitUrl, committedDate, committedViaWeb, committer, deletions, deployments, history, id, message, messageBody, messageBodyHTML, messageHeadline, messageHeadlineHTML, oid, parents, pushedDate, repository, resourcePath, signature, status, tarballUrl, tree, treeResourcePath, treeUrl, url, viewerCanSubscribe, viewerSubscription, zipballUrl)
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册