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

templates.javaClassGraphqlRequest.ftl Maven / Gradle / Ivy

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


import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLOperation;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLOperationRequest;
import java.util.LinkedHashMap;
import java.util.Map;
<#if toString || equalsAndHashCode>
import java.util.Objects;


<#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 GraphQLOperationRequest {

    private static final GraphQLOperation OPERATION_TYPE = GraphQLOperation.${operationType};
    private static final String OPERATION_NAME = "${operationName}";

    private Map input = new LinkedHashMap<>();

    public ${className}() {
    }

<#if fields?has_content>
<#list fields as field>
<#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.input.put("${field.originalName}", ${field.name});
    }



    @Override
    public GraphQLOperation getOperationType() {
        return OPERATION_TYPE;
    }

    @Override
    public String getOperationName() {
        return OPERATION_NAME;
    }

    @Override
    public Map getInput() {
        return input;
    }

<#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;
        return Objects.equals(getOperationType(), that.getOperationType()) &&
                   Objects.equals(getOperationName(), that.getOperationName()) &&
                   Objects.equals(input, that.input);
    }

    @Override
    public int hashCode() {
        return Objects.hash(getOperationType(), getOperationName(), input);
    }

<#if toString>
    @Override
    public String toString() {
        return Objects.toString(input);
    }


<#if 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() {
            ${className} obj = new ${className}();
<#if fields?has_content>
<#list fields as field>
            obj.set${field.name?cap_first}(${field.name});


            return obj;
        }

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy