List of usage examples for java.util Optional or
public Optional<T> or(Supplier<? extends Optional<? extends T>> supplier)
From source file:com.spotify.heroic.metric.astyanax.AstyanaxMetricModule.java
@JsonCreator public AstyanaxMetricModule(@JsonProperty("id") Optional<String> id, @JsonProperty("seeds") Optional<Set<String>> seeds, @JsonProperty("keyspace") Optional<String> keyspace, @JsonProperty("maxConnectionsPerHost") Optional<Integer> maxConnectionsPerHost, @JsonProperty("groups") Optional<Groups> groups, @JsonProperty("pools") Optional<ReadWriteThreadPools.Config> pools) { this.id = id; this.groups = groups.orElseGet(Groups::empty).or(DEFAULT_GROUP); this.keyspace = keyspace.orElse(DEFAULT_KEYSPACE); this.seeds = seeds.orElse(DEFAULT_SEEDS); this.maxConnectionsPerHost = maxConnectionsPerHost.orElse(DEFAULT_MAX_CONNECTIONS_PER_HOST); this.pools = pools.orElseGet(ReadWriteThreadPools.Config::buildDefault); }
From source file:com.spotify.heroic.suggest.elasticsearch.ElasticsearchSuggestModule.java
@JsonCreator public ElasticsearchSuggestModule(@JsonProperty("id") Optional<String> id, @JsonProperty("groups") Optional<Groups> groups, @JsonProperty("connection") Optional<ConnectionModule> connection, @JsonProperty("writesPerSecond") Optional<Double> writesPerSecond, @JsonProperty("rateLimitSlowStartSeconds") Optional<Long> rateLimitSlowStartSeconds, @JsonProperty("writeCacheDurationMinutes") Optional<Long> writeCacheDurationMinutes, @JsonProperty("templateName") Optional<String> templateName, @JsonProperty("backendType") Optional<String> backendType, @JsonProperty("configure") Optional<Boolean> configure) { this.id = id; this.groups = groups.orElseGet(Groups::empty).or(DEFAULT_GROUP); this.connection = connection.orElseGet(ConnectionModule::buildDefault); this.writesPerSecond = writesPerSecond.orElse(DEFAULT_WRITES_PER_SECOND); this.rateLimitSlowStartSeconds = rateLimitSlowStartSeconds.orElse(DEFAULT_RATE_LIMIT_SLOW_START_SECONDS); this.writeCacheDurationMinutes = writeCacheDurationMinutes.orElse(DEFAULT_WRITES_CACHE_DURATION_MINUTES); this.templateName = templateName.orElse(DEFAULT_TEMPLATE_NAME); this.backendType = backendType.orElse(DEFAULT_BACKEND_TYPE); this.type = backendType.map(this::lookupBackendType).orElse(defaultSetup); this.configure = configure.orElse(DEFAULT_CONFIGURE); }
From source file:com.spotify.heroic.metadata.elasticsearch.ElasticsearchMetadataModule.java
@JsonCreator public ElasticsearchMetadataModule(@JsonProperty("id") Optional<String> id, @JsonProperty("groups") Optional<Groups> groups, @JsonProperty("connection") Optional<ConnectionModule> connection, @JsonProperty("writesPerSecond") Optional<Double> writesPerSecond, @JsonProperty("rateLimitSlowStartSeconds") Optional<Long> rateLimitSlowStartSeconds, @JsonProperty("writeCacheDurationMinutes") Optional<Long> writeCacheDurationMinutes, @JsonProperty("deleteParallelism") Optional<Integer> deleteParallelism, @JsonProperty("templateName") Optional<String> templateName, @JsonProperty("backendType") Optional<String> backendType, @JsonProperty("configure") Optional<Boolean> configure) { this.id = id; this.groups = groups.orElseGet(Groups::empty).or(DEFAULT_GROUP); this.connection = connection.orElseGet(ConnectionModule::buildDefault); this.writesPerSecond = writesPerSecond.orElse(DEFAULT_WRITES_PER_SECOND); this.rateLimitSlowStartSeconds = rateLimitSlowStartSeconds.orElse(DEFAULT_RATE_LIMIT_SLOW_START_SECONDS); this.writeCacheDurationMinutes = writeCacheDurationMinutes.orElse(DEFAULT_WRITE_CACHE_DURATION_MINUTES); this.deleteParallelism = deleteParallelism.orElse(DEFAULT_DELETE_PARALLELISM); this.templateName = templateName.orElse(DEFAULT_TEMPLATE_NAME); this.backendTypeBuilder = backendType.flatMap(bt -> ofNullable(backendTypes.get(bt))).orElse(defaultSetup); this.configure = configure.orElse(false); }