org.apache.flink.cdc.common.configuration.ConfigOptions Maven / Gradle / Ivy
The newest version!
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.flink.cdc.common.configuration;
import org.apache.flink.cdc.common.annotation.PublicEvolving;
import org.apache.flink.cdc.common.configuration.description.Description;
import org.apache.flink.cdc.common.utils.Preconditions;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* {@code ConfigOptions} are used to build a {@link ConfigOption}. The option is typically built in
* one of the following pattern:
*
* {@code
* // simple string-valued option with a default value
* ConfigOption tempDirs = ConfigOptions
* .key("tmp.dir")
* .stringType()
* .defaultValue("/tmp");
*
* // simple integer-valued option with a default value
* ConfigOption parallelism = ConfigOptions
* .key("application.parallelism")
* .intType()
* .defaultValue(100);
*
* // option of list of integers with a default value
* ConfigOption parallelism = ConfigOptions
* .key("application.ports")
* .intType()
* .asList()
* .defaultValue(8000, 8001, 8002);
*
* // option with no default value
* ConfigOption userName = ConfigOptions
* .key("user.name")
* .stringType()
* .noDefaultValue();
*
* // option with deprecated keys to check
* ConfigOption threshold = ConfigOptions
* .key("cpu.utilization.threshold")
* .doubleType()
* .defaultValue(0.9)
* .withDeprecatedKeys("cpu.threshold");
* }
*/
@PublicEvolving
public class ConfigOptions {
/**
* Starts building a new {@link ConfigOption}.
*
* @param key The key for the config option.
* @return The builder for the config option with the given key.
*/
public static OptionBuilder key(String key) {
Preconditions.checkNotNull(key);
return new OptionBuilder(key);
}
// ------------------------------------------------------------------------
/**
* The option builder is used to create a {@link ConfigOption}. It is instantiated via {@link
* ConfigOptions#key(String)}.
*/
public static final class OptionBuilder {
/**
* Workaround to reuse the {@link TypedConfigOptionBuilder} for a {@link Map Map<String,
* String>}.
*/
@SuppressWarnings("unchecked")
private static final Class
© 2015 - 2025 Weber Informatics LLC | Privacy Policy