@@ -40,6 +40,10 @@ public ExecutionResultImpl(ExecutionResultImpl other) {
4040 this (other .dataPresent , other .data , other .errors , other .extensions );
4141 }
4242
43+ public <T extends Builder <T >> ExecutionResultImpl (Builder <T > builder ) {
44+ this (builder .dataPresent , builder .data , builder .errors , builder .extensions );
45+ }
46+
4347 private ExecutionResultImpl (boolean dataPresent , Object data , List <? extends GraphQLError > errors , Map <Object , Object > extensions ) {
4448 this .dataPresent = dataPresent ;
4549 this .data = data ;
@@ -103,61 +107,61 @@ public String toString() {
103107 '}' ;
104108 }
105109
106- public static Builder newExecutionResult () {
107- return new Builder ();
110+ public static < T extends Builder < T >> Builder < T > newExecutionResult () {
111+ return new Builder <> ();
108112 }
109113
110- public static class Builder implements ExecutionResult .Builder <Builder > {
114+ public static class Builder < T extends Builder < T >> implements ExecutionResult .Builder <T > {
111115 private boolean dataPresent ;
112116 private Object data ;
113117 private List <GraphQLError > errors = new ArrayList <>();
114118 private Map <Object , Object > extensions ;
115119
116120 @ Override
117- public Builder from (ExecutionResult executionResult ) {
121+ public T from (ExecutionResult executionResult ) {
118122 dataPresent = executionResult .isDataPresent ();
119123 data = executionResult .getData ();
120124 errors = new ArrayList <>(executionResult .getErrors ());
121125 extensions = executionResult .getExtensions ();
122- return this ;
126+ return ( T ) this ;
123127 }
124128
125129 @ Override
126- public Builder data (Object data ) {
130+ public T data (Object data ) {
127131 dataPresent = true ;
128132 this .data = data ;
129- return this ;
133+ return ( T ) this ;
130134 }
131135
132136 @ Override
133- public Builder errors (List <GraphQLError > errors ) {
137+ public T errors (List <GraphQLError > errors ) {
134138 this .errors = errors ;
135- return this ;
139+ return ( T ) this ;
136140 }
137141
138142 @ Override
139- public Builder addErrors (List <GraphQLError > errors ) {
143+ public T addErrors (List <GraphQLError > errors ) {
140144 this .errors .addAll (errors );
141- return this ;
145+ return ( T ) this ;
142146 }
143147
144148 @ Override
145- public Builder addError (GraphQLError error ) {
149+ public T addError (GraphQLError error ) {
146150 this .errors .add (error );
147- return this ;
151+ return ( T ) this ;
148152 }
149153
150154 @ Override
151- public Builder extensions (Map <Object , Object > extensions ) {
155+ public T extensions (Map <Object , Object > extensions ) {
152156 this .extensions = extensions ;
153- return this ;
157+ return ( T ) this ;
154158 }
155159
156160 @ Override
157- public Builder addExtension (String key , Object value ) {
161+ public T addExtension (String key , Object value ) {
158162 this .extensions = (this .extensions == null ? new LinkedHashMap <>() : this .extensions );
159163 this .extensions .put (key , value );
160- return this ;
164+ return ( T ) this ;
161165 }
162166
163167 @ Override
0 commit comments