ConfigurationElement
@propertyWrapper
public struct ConfigurationElement<T> : Equatable where T : Equatable, T : AcceptableByConfigurationElement
A single parameter of a rule configuration.
Apply it to a simple (e.g. boolean) property like
@ConfigurationElement(key: "name")
var property = true
If the wrapped element is an InlinableOptionType
, there are two options for its representation
in the documentation:
- It can be inlined into the parent configuration. For that, do not provide a name as an argument. E.g.
swift @ConfigurationElement(key: "name") var property = true @ConfigurationElement var levels = SeverityLevelsConfiguration(warning: 1, error: 2)
will be documented as a linear list:name: true warning: 1 error: 2
- It can be represented as a separate nested configuration. In this case, it must have a name. E.g.
swift @ConfigurationElement(key: "name") var property = true @ConfigurationElement(key: "levels") var levels = SeverityLevelsConfiguration(warning: 1, error: 2)
will have a nested configuration section:name: true levels: warning: 1 error: 2
-
Wrapped option value.
Declaration
Swift
public var wrappedValue: T
-
The wrapper itself providing access to all its data. This field can only be accessed by the element’s name prefixed with a
$
.Declaration
Swift
public var projectedValue: ConfigurationElement { get set }
-
Name of this configuration entry.
Declaration
Swift
public let key: String
-
Default constructor.
Declaration
Swift
public init(wrappedValue value: T, key: String, postprocessor: @escaping (inout T) throws -> Void = { _ in })
Parameters
value
Value to be wrapped.
key
Name of the option.
postprocessor
Function to be applied to the wrapped value after parsing to validate and modify it.
-
Constructor for optional values.
It allows to skip explicit initialization with
nil
of the property.Declaration
Swift
public init<Wrapped>(key: String) where T == Wrapped?, Wrapped : Equatable, Wrapped : AcceptableByConfigurationElement
Parameters
value
Value to be wrapped.
-
Constructor for a
ConfigurationElement
without a key.InlinableOptionType
s are allowed to have an empty key. The configuration will be inlined into its parent configuration in this specific case.Declaration
Swift
public init(wrappedValue value: T) where T : InlinableOptionType
Parameters
value
Value to be wrapped.
-
Run operations to validate and modify the parsed value.
Declaration
Swift
public mutating func performAfterParseOperations() throws
-
Declaration
Swift
public static func == (lhs: ConfigurationElement, rhs: ConfigurationElement) -> Bool