Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiFunction;
import static org.apache.flink.cdc.common.configuration.ConfigurationUtils.canBePrefixMap;
import static org.apache.flink.cdc.common.configuration.ConfigurationUtils.containsPrefixMap;
import static org.apache.flink.cdc.common.configuration.ConfigurationUtils.convertToPropertiesPrefixed;
import static org.apache.flink.cdc.common.configuration.ConfigurationUtils.removePrefixMap;
/** Lightweight configuration object which stores key/value pairs. */
public class Configuration implements java.io.Serializable, Cloneable {
private static final long serialVersionUID = 1L;
/** The log object used for debugging. */
private static final Logger LOG = LoggerFactory.getLogger(Configuration.class);
/** Stores the concrete key/value pairs of this configuration object. */
protected final HashMap confData;
// --------------------------------------------------------------------------------------------
/** Creates a new empty configuration. */
public Configuration() {
this.confData = new HashMap<>();
}
/**
* Creates a new configuration with the copy of the given configuration.
*
* @param other The configuration to copy the entries from.
*/
public Configuration(Configuration other) {
this.confData = new HashMap<>(other.confData);
}
/** Creates a new configuration that is initialized with the options of the given map. */
public static Configuration fromMap(Map map) {
final Configuration configuration = new Configuration();
configuration.confData.putAll(map);
return configuration;
}
public void addAll(Configuration other) {
synchronized (this.confData) {
synchronized (other.confData) {
this.confData.putAll(other.confData);
}
}
}
@Override
public Configuration clone() {
Configuration config = new Configuration();
config.addAll(this);
return config;
}
/**
* Checks whether there is an entry for the given config option.
*
* @param configOption The configuration option
* @return true if a valid (current or deprecated) key of the config option is stored,
* false otherwise
*/
public boolean contains(ConfigOption> configOption) {
synchronized (this.confData) {
final BiFunction> applier =
(key, canBePrefixMap) -> {
if (canBePrefixMap && containsPrefixMap(this.confData, key)
|| this.confData.containsKey(key)) {
return Optional.of(true);
}
return Optional.empty();
};
return applyWithOption(configOption, applier).orElse(false);
}
}
public T get(ConfigOption option) {
return getOptional(option).orElseGet(option::defaultValue);
}
public Optional getOptional(ConfigOption option) {
Optional