com.swirlds.config.api.ConfigurationExtension Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swirlds-config-api Show documentation
Show all versions of swirlds-config-api Show documentation
Swirlds is a software platform designed to build fully-distributed applications that harness the power of the cloud without servers. Now you can develop applications with fairness in decision making, speed, trust and reliability, at a fraction of the cost of traditional server-based platforms.
The newest version!
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed 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 com.swirlds.config.api;
import com.swirlds.config.api.converter.ConfigConverter;
import com.swirlds.config.api.source.ConfigSource;
import com.swirlds.config.api.validation.ConfigValidator;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Collections;
import java.util.Set;
/**
* The {@link ConfigurationExtension} is used to extend the configuration api with additional configuration types,
* converters, validators and sources. This is useful for plugins or modules that want to add their own configuration
* types to the configuration api.
*
* The extension will be discovered by the configuration api using SPI (Service Provider Interface) and must be
* registered in the {@code module-info.java} file of the module that contains the extension.
*/
public interface ConfigurationExtension {
/**
* Returns a collection of configuration data types that should be added to the configuration api. The returned
* collection must not be null.
*
* @return a collection of configuration data types
*/
@NonNull
default Set> getConfigDataTypes() {
return Collections.emptySet();
}
/**
* Returns a collection of configuration converters that should be added to the configuration api. The returned
* collection must not be null.
*
* @return a collection of configuration converters
*/
@NonNull
default Set> getConverters() {
return Collections.emptySet();
}
/**
* Returns a collection of configuration validators that should be added to the configuration api. The returned
* collection must not be null.
*
* @return a collection of configuration validators
*/
@NonNull
default Set getValidators() {
return Collections.emptySet();
}
/**
* Returns a collection of configuration sources that should be added to the configuration api. The returned
* collection must not be null.
*
* @return a collection of configuration sources
*/
@NonNull
default Set getConfigSources() {
return Collections.emptySet();
}
/**
* A pair of type and its corresponding converter.
*
* @param type type to convert
* @param converter converter to use
* @param type to convert
*/
record ConverterPair(@NonNull Class type, @NonNull ConfigConverter converter) {
public static ConverterPair of(Class type, ConfigConverter converter) {
return new ConverterPair<>(type, converter);
}
}
}