/** Creates a new builder using {@code value} as a template. */ public static StorageClientSettings.Builder from(StorageClientSettings value) { return StorageClientSettings.newBuilder().mergeFrom(value); }
static Builder newBuilder() { // builder with default values return new Builder(); }
/** * If the value to be returned by {@link StorageClientSettings#statsLogger()} is present, replaces * it by applying {@code mapper} to it and using the result. * * <p>If the result is null, clears the value. * * @return this {@code Builder} object * @throws NullPointerException if {@code mapper} is null */ public StorageClientSettings.Builder mapStatsLogger(UnaryOperator<StatsLogger> mapper) { return statsLogger(statsLogger().map(mapper)); }
@Override public StorageClientSettings build() { StorageClientSettings settings = super.build(); // create a service uri to ensure the service uri is valid ServiceURI.create(serviceUri()); return settings; } }
/** Resets the state of this builder. */ public StorageClientSettings.Builder clear() { StorageClientSettings_Builder _defaults = StorageClientSettings.newBuilder(); numWorkerThreads = _defaults.numWorkerThreads; serviceUri = _defaults.serviceUri; endpointResolver = _defaults.endpointResolver; usePlaintext = _defaults.usePlaintext; clientName = _defaults.clientName; statsLogger = _defaults.statsLogger; backoffPolicy = _defaults.backoffPolicy; enableServerSideRouting = _defaults.enableServerSideRouting; _unsetProperties.clear(); _unsetProperties.addAll(_defaults._unsetProperties); return (StorageClientSettings.Builder) this; }
/** * Sets the value to be returned by {@link StorageClientSettings#statsLogger()}. * * @return this {@code Builder} object */ public StorageClientSettings.Builder nullableStatsLogger(@Nullable StatsLogger statsLogger) { if (statsLogger != null) { return statsLogger(statsLogger); } else { return clearStatsLogger(); } }
/** * Sets the value to be returned by {@link StorageClientSettings#clientName()}. * * @return this {@code Builder} object */ public StorageClientSettings.Builder nullableClientName(@Nullable String clientName) { if (clientName != null) { return clientName(clientName); } else { return clearClientName(); } }
@Override public StorageServerChannel apply(Endpoint endpoint) { StorageServerChannel channel = new StorageServerChannel( endpoint, Optional.empty(), settings.usePlaintext(), settings.endpointResolver()); return interceptor .map(interceptor -> channel.intercept(interceptor)) .orElse(channel); } };
protected SimpleClientBase(StorageClientSettings settings, Resource<OrderedScheduler> schedulerResource) { this( settings, schedulerResource, GrpcChannels.createChannelBuilder(settings.serviceUri(), settings).build(), true); }
/** * Replaces the value to be returned by {@link StorageClientSettings#usePlaintext()} by applying * {@code mapper} to it and using the result. * * @return this {@code Builder} object * @throws NullPointerException if {@code mapper} is null or returns null */ public StorageClientSettings.Builder mapUsePlaintext(UnaryOperator<Boolean> mapper) { return usePlaintext(mapper.apply(usePlaintext())); }
/** * If the value to be returned by {@link StorageClientSettings#clientName()} is present, replaces * it by applying {@code mapper} to it and using the result. * * <p>If the result is null, clears the value. * * @return this {@code Builder} object * @throws NullPointerException if {@code mapper} is null */ public StorageClientSettings.Builder mapClientName(UnaryOperator<String> mapper) { return clientName(clientName().map(mapper)); }
/** * Replaces the value to be returned by {@link StorageClientSettings#enableServerSideRouting()} by * applying {@code mapper} to it and using the result. * * @return this {@code Builder} object * @throws NullPointerException if {@code mapper} is null or returns null */ public StorageClientSettings.Builder mapEnableServerSideRouting(UnaryOperator<Boolean> mapper) { return enableServerSideRouting(mapper.apply(enableServerSideRouting())); }
/** * Replaces the value to be returned by {@link StorageClientSettings#endpointResolver()} by * applying {@code mapper} to it and using the result. * * @return this {@code Builder} object * @throws NullPointerException if {@code mapper} is null or returns null */ public StorageClientSettings.Builder mapEndpointResolver(UnaryOperator<EndpointResolver> mapper) { return endpointResolver(mapper.apply(endpointResolver())); }
/** * Replaces the value to be returned by {@link StorageClientSettings#numWorkerThreads()} by * applying {@code mapper} to it and using the result. * * @return this {@code Builder} object * @throws NullPointerException if {@code mapper} is null or returns null */ public StorageClientSettings.Builder mapNumWorkerThreads(UnaryOperator<Integer> mapper) { return numWorkerThreads(mapper.apply(numWorkerThreads())); }
/** * Replaces the value to be returned by {@link StorageClientSettings#backoffPolicy()} by applying * {@code mapper} to it and using the result. * * @return this {@code Builder} object * @throws NullPointerException if {@code mapper} is null or returns null */ public StorageClientSettings.Builder mapBackoffPolicy(UnaryOperator<Backoff.Policy> mapper) { return backoffPolicy(mapper.apply(backoffPolicy())); }
/** * Returns a newly-created partial {@link StorageClientSettings} for use in unit tests. State * checking will not be performed. Unset properties will throw an {@link * UnsupportedOperationException} when accessed via the partial object. * * <p>Partials should only ever be used in tests. They permit writing robust test cases that won't * fail if this type gains more application-level constraints (e.g. new required fields) in * future. If you require partially complete values in production code, consider using a Builder. */ @VisibleForTesting() public StorageClientSettings buildPartial() { return new StorageClientSettings_Builder.Partial(this); }
/** * Replaces the value to be returned by {@link StorageClientSettings#serviceUri()} by applying * {@code mapper} to it and using the result. * * @return this {@code Builder} object * @throws NullPointerException if {@code mapper} is null or returns null * @throws IllegalStateException if the field has not been set */ public StorageClientSettings.Builder mapServiceUri(UnaryOperator<String> mapper) { Preconditions.checkNotNull(mapper); return serviceUri(mapper.apply(serviceUri())); }
/** * Returns a newly-created {@link StorageClientSettings} based on the contents of the {@code * Builder}. * * @throws IllegalStateException if any field has not been set */ public StorageClientSettings build() { Preconditions.checkState(_unsetProperties.isEmpty(), "Not set: %s", _unsetProperties); return new StorageClientSettings_Builder.Value(this); }
/** * Sets the value to be returned by {@link StorageClientSettings#statsLogger()}. * * @return this {@code Builder} object */ public StorageClientSettings.Builder statsLogger(Optional<? extends StatsLogger> statsLogger) { if (statsLogger.isPresent()) { return statsLogger(statsLogger.get()); } else { return clearStatsLogger(); } }
/** * Sets the value to be returned by {@link StorageClientSettings#clientName()}. * * @return this {@code Builder} object */ public StorageClientSettings.Builder clientName(Optional<? extends String> clientName) { if (clientName.isPresent()) { return clientName(clientName.get()); } else { return clearClientName(); } }