CaptureRequestOptions

@ExperimentalCamera2Interop
@RequiresApi(value = 21)
public class CaptureRequestOptions


A bundle of Camera2 capture request options.

Summary

Nested types

@RequiresApi(value = 21)
public final class CaptureRequestOptions.Builder implements ExtendableBuilder

Builder for creating CaptureRequestOptions instance.

Public methods

boolean

Returns whether this configuration contains the supplied option.

void
findOptions(
    @NonNull String idSearchString,
    @NonNull Config.OptionMatcher matcher
)

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

@Nullable ValueT

Returns a value for the given CaptureRequest.Key or null if it hasn't been set.

@NonNull Config.OptionPriority

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

@NonNull Set<Config.OptionPriority>

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

static boolean
hasConflict(
    @NonNull Config.OptionPriority priority1,
    @NonNull Config.OptionPriority priority2
)

Returns if values with these OptionPriority conflict or not.

@NonNull Set<Config.Option<Object>>

Lists all options contained within this configuration.

static @NonNull Config
mergeConfigs(@Nullable Config extendedConfig, @Nullable Config baseConfig)

Merges two configs.

static void
mergeOptionValue(
    @NonNull MutableOptionsBundle mergedConfig,
    @NonNull Config baseConfig,
    @NonNull Config extendedConfig,
    @NonNull Config.Option<Object> opt
)

Merges a specific option value from two configs.

@Nullable ValueT
<ValueT> retrieveOption(@NonNull Config.Option<ValueT> id)

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

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

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

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

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

@Nullable ValueT
<ValueT> retrieveOptionWithPriority(
    @NonNull Config.Option<ValueT> id,
    @NonNull Config.OptionPriority priority
)

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

Public methods

containsOption

public boolean containsOption(@NonNull Config.Option<Object> id)

Returns whether this configuration contains the supplied option.

Parameters
@NonNull Config.Option<Object> id

The Option to search for in this configuration.

Returns
boolean

true if this configuration contains the supplied option; false otherwise.

findOptions

public void findOptions(
    @NonNull String idSearchString,
    @NonNull Config.OptionMatcher matcher
)

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

Parameters
@NonNull String idSearchString

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\".

@NonNull Config.OptionMatcher matcher

A callback used to receive results of the search. Results will be sent to onOptionMatched in the order in which they are found inside this configuration. Subsequent results will continue to be sent as long as onOptionMatched returns true.

getCaptureRequestOption

Added in 1.0.0
public @Nullable ValueT <ValueT> getCaptureRequestOption(@NonNull CaptureRequest.Key<ValueT> key)

Returns a value for the given CaptureRequest.Key or null if it hasn't been set.

Parameters
<ValueT>

The type of the value.

@NonNull CaptureRequest.Key<ValueT> key

The key to retrieve.

Returns
@Nullable ValueT

The stored value or null if the value does not exist in this configuration.

getOptionPriority

public @NonNull Config.OptionPriority getOptionPriority(@NonNull Config.Option<Object> opt)

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

public @NonNull Set<Config.OptionPrioritygetPriorities(@NonNull Config.Option<Object> option)

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

hasConflict

public static boolean hasConflict(
    @NonNull Config.OptionPriority priority1,
    @NonNull Config.OptionPriority priority2
)

Returns if values with these OptionPriority conflict or not.

Currently it is not allowed the same option to have different values with priority REQUIRED.

listOptions

public @NonNull Set<Config.Option<Object>> listOptions()

Lists all options contained within this configuration.

Returns
@NonNull Set<Config.Option<Object>>

A Set of Options contained within this configuration.

mergeConfigs

public static @NonNull Config mergeConfigs(@Nullable Config extendedConfig, @Nullable Config baseConfig)

Merges two configs.

Parameters
@Nullable Config extendedConfig

the extended config. The options in the extendedConfig will be applied on top of the baseConfig based on the option priorities.

@Nullable Config baseConfig

the base config.

Returns
@NonNull Config

a MutableOptionsBundle of the merged config.

mergeOptionValue

public static void mergeOptionValue(
    @NonNull MutableOptionsBundle mergedConfig,
    @NonNull Config baseConfig,
    @NonNull Config extendedConfig,
    @NonNull Config.Option<Object> opt
)

Merges a specific option value from two configs.

Parameters
@NonNull MutableOptionsBundle mergedConfig

the final output config.

@NonNull Config baseConfig

the base config contains the option value which might be overridden by the corresponding option value in the extend config.

@NonNull Config extendedConfig

the extended config contains the option value which might override the corresponding option value in the base config.

@NonNull Config.Option<Object> opt

the option to merge.

retrieveOption

public @Nullable ValueT <ValueT> retrieveOption(@NonNull Config.Option<ValueT> id)

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
<ValueT>

The type for the value associated with the supplied Option.

@NonNull Config.Option<ValueT> id

The Option to search for in this configuration.

Returns
@Nullable ValueT

The value stored in this configuration.

Throws
java.lang.IllegalArgumentException

if the given option does not exist in this configuration.

retrieveOption

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

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
<ValueT>

The type for the value associated with the supplied Option.

@NonNull Config.Option<ValueT> id

The Option to search for in this configuration.

@Nullable ValueT valueIfMissing

The value to return if the specified Option does not exist in this configuration.

Returns
@Nullable ValueT

The value stored in this configuration, or valueIfMissing if it does not exist.

retrieveOption

public @Nullable ValueT <ValueT> retrieveOption(
    @NonNull Config.Option<ValueT> id,
    @Nullable ValueT valueIfMissing
)

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
<ValueT>

The type for the value associated with the supplied Option.

@NonNull Config.Option<ValueT> id

The Option to search for in this configuration.

@Nullable ValueT valueIfMissing

The value to return if the specified Option does not exist in this configuration.

Returns
@Nullable ValueT

The value stored in this configuration, or valueIfMissing if it does not exist.

retrieveOptionWithPriority

public @Nullable ValueT <ValueT> retrieveOptionWithPriority(
    @NonNull Config.Option<ValueT> id,
    @NonNull Config.OptionPriority priority
)

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
<ValueT>

The type for the value associated with the supplied Option.

@NonNull Config.Option<ValueT> id

The Option to search for in this configuration.

Throws
java.lang.IllegalArgumentException

if the given option with specified priority does not exist in this configuration.