1616
1717package io .grpc .internal ;
1818
19+ import static com .google .common .base .Preconditions .checkArgument ;
20+ import static com .google .common .base .Preconditions .checkNotNull ;
21+
1922import com .google .common .annotations .VisibleForTesting ;
20- import com .google .common .base .Preconditions ;
2123import com .google .common .util .concurrent .MoreExecutors ;
2224import io .grpc .BinaryLog ;
2325import io .grpc .BindableService ;
@@ -105,13 +107,8 @@ List<? extends InternalServer> buildClientTransportServers(
105107 * Creates a new server builder with given transport servers provider.
106108 */
107109 public ServerImplBuilder (ClientTransportServersBuilder clientTransportServersBuilder ) {
108- this .clientTransportServersBuilder = Preconditions
109- .checkNotNull (clientTransportServersBuilder , "clientTransportServersBuilder" );
110- }
111-
112- @ Override
113- public ServerImplBuilder useTransportSecurity (File certChain , File privateKey ) {
114- throw new UnsupportedOperationException ("TLS not supported in ServerImplBuilder" );
110+ this .clientTransportServersBuilder = checkNotNull (clientTransportServersBuilder ,
111+ "clientTransportServersBuilder" );
115112 }
116113
117114 @ Override
@@ -127,30 +124,30 @@ public ServerImplBuilder executor(@Nullable Executor executor) {
127124
128125 @ Override
129126 public ServerImplBuilder addService (ServerServiceDefinition service ) {
130- registryBuilder .addService (Preconditions . checkNotNull (service , "service" ));
127+ registryBuilder .addService (checkNotNull (service , "service" ));
131128 return this ;
132129 }
133130
134131 @ Override
135132 public ServerImplBuilder addService (BindableService bindableService ) {
136- return addService (Preconditions . checkNotNull (bindableService , "bindableService" ).bindService ());
133+ return addService (checkNotNull (bindableService , "bindableService" ).bindService ());
137134 }
138135
139136 @ Override
140137 public ServerImplBuilder addTransportFilter (ServerTransportFilter filter ) {
141- transportFilters .add (Preconditions . checkNotNull (filter , "filter" ));
138+ transportFilters .add (checkNotNull (filter , "filter" ));
142139 return this ;
143140 }
144141
145142 @ Override
146143 public ServerImplBuilder intercept (ServerInterceptor interceptor ) {
147- interceptors .add (Preconditions . checkNotNull (interceptor , "interceptor" ));
144+ interceptors .add (checkNotNull (interceptor , "interceptor" ));
148145 return this ;
149146 }
150147
151148 @ Override
152149 public ServerImplBuilder addStreamTracerFactory (ServerStreamTracer .Factory factory ) {
153- streamTracerFactories .add (Preconditions . checkNotNull (factory , "factory" ));
150+ streamTracerFactories .add (checkNotNull (factory , "factory" ));
154151 return this ;
155152 }
156153
@@ -174,9 +171,8 @@ public ServerImplBuilder compressorRegistry(@Nullable CompressorRegistry registr
174171
175172 @ Override
176173 public ServerImplBuilder handshakeTimeout (long timeout , TimeUnit unit ) {
177- Preconditions
178- .checkArgument (timeout > 0 , "handshake timeout is %s, but must be positive" , timeout );
179- this .handshakeTimeoutMillis = Preconditions .checkNotNull (unit , "unit" ).toMillis (timeout );
174+ checkArgument (timeout > 0 , "handshake timeout is %s, but must be positive" , timeout );
175+ this .handshakeTimeoutMillis = checkNotNull (unit , "unit" ).toMillis (timeout );
180176 return this ;
181177 }
182178
@@ -235,7 +231,7 @@ public void setTracingEnabled(boolean value) {
235231 * Sets a custom deadline ticker. This should only be called from InProcessServerBuilder.
236232 */
237233 public void setDeadlineTicker (Deadline .Ticker ticker ) {
238- this .ticker = Preconditions . checkNotNull (ticker , "ticker" );
234+ this .ticker = checkNotNull (ticker , "ticker" );
239235 }
240236
241237 @ Override
@@ -342,4 +338,9 @@ public List<ServerServiceDefinition> getServices() {
342338 public ObjectPool <? extends Executor > getExecutorPool () {
343339 return this .executorPool ;
344340 }
341+
342+ @ Override
343+ public ServerImplBuilder useTransportSecurity (File certChain , File privateKey ) {
344+ throw new UnsupportedOperationException ("TLS not supported in ServerImplBuilder" );
345+ }
345346}
0 commit comments