Config

@RequiresApi(21) interface Config
androidx.camera.core.impl.Config

A Config is a collection of options and values.

Config object hold pairs of Options/Values and offer methods for querying whether Options are contained in the configuration along with methods for retrieving the associated values for options.

Config allows different values to be set with different OptionPriority on the same Option. While Config#retrieveOption will return the option value of the highest priority, Config#retrieveOptionWithPriority and Config#getPriorities can be used to retrieve option value of specified priority.

Summary

Nested classes
abstract

An Option is used to set and retrieve values for settings defined in a .

abstract

A callback for retrieving results of a Config.Option search.

Defines the priorities for resolving conflicting options.

Public methods
abstract Boolean
containsOption(@NonNull id: Config.Option<*>)

Returns whether this configuration contains the supplied option.

abstract Unit
findOptions(@NonNull idSearchString: String, @NonNull matcher: Config.OptionMatcher)

Search the configuration for Options whose id match the supplied search string.

abstract Config.OptionPriority
getOptionPriority(@NonNull opt: Config.Option<*>)

Returns the current priority of the value for the specified option.

abstract MutableSet<Config.OptionPriority!>
getPriorities(@NonNull option: Config.Option<*>)

Returns a Set of all priorities set for the specified option.

open static Boolean
hasConflict(@NonNull priority1: Config.OptionPriority, @NonNull priority2: Config.OptionPriority)

Returns if values with these OptionPriority conflict or not.

abstract MutableSet<Config.Option<*>!>

Lists all options contained within this configuration.

open static Config
mergeConfigs(@Nullable extendedConfig: Config?, @Nullable baseConfig: Config?)

Merges two configs

abstract ValueT?
retrieveOption(@NonNull id: Config.Option<ValueT>)

Retrieves the value for the specified option if it exists in the configuration.

abstract ValueT?
retrieveOption(@NonNull id: Config.Option<ValueT>, @Nullable valueIfMissing: ValueT?)

Retrieves the value for the specified option if it exists in the configuration.

abstract ValueT?
retrieveOptionWithPriority(@NonNull id: Config.Option<ValueT>, @NonNull priority: Config.OptionPriority)

Retrieves the value for the specified option and specified priority if it exists in the configuration.

Public methods

containsOption

abstract fun containsOption(@NonNull id: Config.Option<*>): Boolean

Returns whether this configuration contains the supplied option.

Parameters
id Config.Option<*>: The Option to search for in this configuration.
Return
Boolean true if this configuration contains the supplied option; false otherwise.

findOptions

abstract fun findOptions(
    @NonNull idSearchString: String,
    @NonNull matcher: Config.OptionMatcher
): Unit

Search the configuration for Options whose id match the supplied search string.

Parameters
idSearchString String: The id string to search for. This could be a fully qualified id such as \"camerax.core.example.option\" or the stem for an option such as \" camerax.core.example\".
matcher Config.OptionMatcher: A callback used to receive results of the search. Results will be sent to OptionMatcher#onOptionMatched(Option) in the order in which they are found inside this configuration. Subsequent results will continue to be sent as long as OptionMatcher#onOptionMatched(Option) returns true.

getOptionPriority

@NonNull abstract fun getOptionPriority(@NonNull opt: Config.Option<*>): Config.OptionPriority

Returns the current priority of the value for the specified option.

If there are multiple values of various priorities for the specified options, the highest priority will be returned. If the option does not exist, an IllegalArgumentException will be thrown.

getPriorities

@NonNull abstract fun getPriorities(@NonNull option: Config.Option<*>): MutableSet<Config.OptionPriority!>

Returns a Set of all priorities set for the specified option.

hasConflict

open static fun hasConflict(
    @NonNull priority1: Config.OptionPriority,
    @NonNull priority2: Config.OptionPriority
): Boolean

Returns if values with these OptionPriority conflict or not. Currently it is not allowed to have different values with same ALWAYS_OVERRIDE priority or to have different values with same REQUIRED priority.

listOptions

@NonNull abstract fun listOptions(): MutableSet<Config.Option<*>!>

Lists all options contained within this configuration.

Return
MutableSet<Config.Option<*>!> A Set of Options contained within this configuration.

mergeConfigs

@NonNull open static fun mergeConfigs(
    @Nullable extendedConfig: Config?,
    @Nullable baseConfig: Config?
): Config

Merges two configs

Parameters
extendedConfig Config?: the extended config. The options in the extendedConfig will be applied on top of the baseConfig based on the option priorities.
baseConfig Config?: the base config
Return
Config a MutableOptionsBundle of the merged config

retrieveOption

@Nullable abstract fun <ValueT : Any!> retrieveOption(@NonNull id: Config.Option<ValueT>): ValueT?

Retrieves the value for the specified option if it exists in the configuration.

If the option does not exist, an exception will be thrown. If there are multiple values being set with multiple OptionPriority, it will return the value of highest priority.

Parameters
id Config.Option<ValueT>: The Option to search for in this configuration.
<ValueT> The type for the value associated with the supplied Option.
Return
ValueT? The value stored in this configuration, or null if it does not exist.
Exceptions
IllegalArgumentException if the given option does not exist in this configuration.

retrieveOption

@Nullable abstract fun <ValueT : Any!> retrieveOption(
    @NonNull id: Config.Option<ValueT>,
    @Nullable valueIfMissing: ValueT?
): ValueT?

Retrieves the value for the specified option if it exists in the configuration.

If the option does not exist, valueIfMissing will be returned. If there are multiple values being set with multiple OptionPriority, it will return the value of highest priority.

Parameters
id Config.Option<ValueT>: The Option to search for in this configuration.
valueIfMissing ValueT?: The value to return if the specified Option does not exist in this configuration.
<ValueT> The type for the value associated with the supplied Option.
Return
ValueT? The value stored in this configuration, or null if it does not exist.

retrieveOptionWithPriority

@Nullable abstract fun <ValueT : Any!> retrieveOptionWithPriority(
    @NonNull id: Config.Option<ValueT>,
    @NonNull priority: Config.OptionPriority
): ValueT?

Retrieves the value for the specified option and specified priority if it exists in the configuration.

If the option does not exist, an exception will be thrown.

Parameters
id Config.Option<ValueT>: The Option to search for in this configuration.
<ValueT> The type for the value associated with the supplied Option.
Exceptions
IllegalArgumentException if the given option with specified priority does not exist in this configuration.