All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.javaClassGraphqlType.ftl Maven / Gradle / Ivy

The newest version!
<#if package?has_content>
package ${package};


<#if imports??>
<#list imports as import>
import ${import}.*;


<#if toStringForRequest>
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLRequestSerializer;

<#if equalsAndHashCode>
import java.util.Objects;

<#if toString>
import java.util.StringJoiner;


<#if javaDoc?has_content>
/**
<#list javaDoc as javaDocLine>
 * ${javaDocLine}

 */

<#if generatedInfo.getGeneratedType()?has_content>
@${generatedInfo.getGeneratedType()}(
    value = "com.kobylynskyi.graphql.codegen.GraphQLCodegen",
    date = "${generatedInfo.getDateTime()}"
)

<#list annotations as annotation>
@${annotation}

public class ${className} implements java.io.Serializable<#if implements?has_content><#list implements as interface>, ${interface}<#if interface_has_next> {

<#if fields?has_content>
<#list fields as field>
<#if field.deprecated>
    @Deprecated

<#list field.annotations as annotation>
    @${annotation}

    private ${field.type} ${field.name}<#if field.defaultValue?has_content> = ${field.defaultValue};



    public ${className}() {
    }

<#if fields?has_content>
    public ${className}(<#list fields as field>${field.type} ${field.name}<#if field_has_next>, ) {
<#list fields as field>
        this.${field.name} = ${field.name};

    }


<#if fields?has_content>
<#list fields as field>
<#if field.javaDoc?has_content>
    /**
<#list field.javaDoc as javaDocLine>
     * ${javaDocLine}

     */

<#if field.deprecated>
    @Deprecated

    public ${field.type} get${field.name?cap_first}() {
        return ${field.name};
    }
<#if !immutableModels>
<#if field.javaDoc?has_content>
    /**
<#list field.javaDoc as javaDocLine>
     * ${javaDocLine}

     */

<#if field.deprecated>
    @Deprecated

    public void set${field.name?cap_first}(${field.type} ${field.name}) {
        this.${field.name} = ${field.name};
    }




<#if equalsAndHashCode>
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        final ${className} that = (${className}) obj;
<#if fields?has_content>
        return <#list fields as field>Objects.equals(${field.name}, that.${field.name})<#if field_has_next>
            && ;
<#else>
        return true;

    }

    @Override
    public int hashCode() {
<#if fields?has_content>
        return Objects.hash(<#list fields as field>${field.name}<#if field_has_next>, );
<#else>
        return 0;

    }


<#if toString>
    @Override
    public String toString() {
        StringJoiner joiner = new StringJoiner(", ", "{ ", " }");
<#if fields?has_content>
<#list fields as field>
        if (${field.name} != null) {
<#if toStringForRequest>
            joiner.add("${field.originalName}: " + GraphQLRequestSerializer.getEntry(${field.name}));
<#else>
<#if field.type == "String">
            joiner.add("${field.originalName}: \"" + ${field.name} + "\"");
<#else>
            joiner.add("${field.originalName}: " + ${field.name});


        }


        return joiner.toString();
    }


<#if builder>
    public static ${className}.Builder builder() {
        return new ${className}.Builder();
    }

    public static class Builder {

<#if fields?has_content>
<#list fields as field>
        private ${field.type} ${field.name}<#if field.defaultValue?has_content> = ${field.defaultValue};



        public Builder() {
        }

<#if fields?has_content>
<#list fields as field>
<#if field.javaDoc?has_content>
        /**
<#list field.javaDoc as javaDocLine>
         * ${javaDocLine}

         */

<#if field.deprecated>
        @Deprecated

        public Builder set${field.name?cap_first}(${field.type} ${field.name}) {
            this.${field.name} = ${field.name};
            return this;
        }




        public ${className} build() {
            return new ${className}(<#list fields as field>${field.name}<#if field_has_next>, );
        }

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy