StructureBase

open class StructureBase : DataValue, Codable, @unchecked Sendable

Common base class for ComplexValue and EntityValue.

  • Decode and initialize a new object instance

    Declaration

    Swift

    public required init(from decoder: Decoder) throws

    Parameters

    from

    decoder object which contains the original object’s serialized data in a container instance

  • Abstract function to encode the object instance

    Declaration

    Swift

    public func encode(to encoder: Encoder) throws

    Parameters

    to

    encoder object which can be used to serialize the object’s data one by one into a container instance

  • Default initializer.

    Declaration

    Swift

    override public init()
  • Instance annotations for this structure. Initialized to immutable AnnotationMap.empty. Must be replaced with a mutable map if needed.

    Declaration

    Swift

    public final var annotations: AnnotationMap { get set }
  • Resource path for this structure (relative to service root).

    Declaration

    Swift

    public final var dataPath: DataPath? { get set }
  • Get the value of a specified property path.

    Throws

    UndefinedException if the property value was not previously set.

    See also

    hasDataValue.

    Declaration

    Swift

    public final func dataValue(for path: PropertyPath) -> DataValue?

    Parameters

    path

    The specified property path.

    Return Value

    The property value, as an instance of the appropriate subclass of DataValue, or nil if the property value is nil.

  • Holds dynamic property values, for which metadata is not known in advance.

    See also

    ComplexType.isOpenType, EntityType.isOpenType.

    Declaration

    Swift

    public final var dynamicProperties: DataValueMap { get set }
  • See also

    dynamicProperties.

    Declaration

    Swift

    public final func dynamicValue(name: String) -> DataValue?

    Parameters

    name

    Name of a dynamic property.

    Return Value

    The value of a dynamic property, or nil if no such property exists.

  • Declaration

    Swift

    open func hasChangedProperties() -> Bool

    Return Value

    true if this structure has one or more changed properties. Seee ComplexValue.oldComplex, EntityValue.oldEntity.

  • Declaration

    Swift

    public final func hasDataType(_ type: DataType) -> Bool

    Parameters

    type

    Specified data type.

    Return Value

    true if this structure has the specified data type (or a subtype).

  • Declaration

    Swift

    public final func hasDataValue(for property: Property) -> Bool

    Parameters

    property

    The specified property.

    Return Value

    true if this structure contains an explicitly set value for the specified property (including nil, if Property.isNullable).

  • True if the structure has dynamic properties set.

    Declaration

    Swift

    public final var hasDynamicProperties: Bool { get }
  • Declaration

    Swift

    public final func hasNextLink(for property: Property) -> Bool

    Parameters

    property

    The specified property.

    Return Value

    true if this structure contains a next-link for the specified collection-typed property.

  • Declaration

    Swift

    open func isNewOrChanged(property: Property) -> Bool

    Parameters

    property

    Structural property.

    Return Value

    true if the value of property property is new or changed.

  • Is this structure an instance of a generated proxy class?

    Declaration

    Swift

    open var isProxy: Bool { get }
  • Get the next-link of a specified collection-typed property path.

    See also

    hasNextLink.

    Declaration

    Swift

    public final func nextLink(for path: PropertyPath) -> String?

    Parameters

    path

    The specified property path.

    Return Value

    The next-link, or nil if there is no next link for the specified path.

  • Get the optional value of a specified property path.

    Declaration

    Swift

    public final func optionalValue(for path: PropertyPath) -> DataValue?

    Parameters

    path

    The specified property path.

    Return Value

    The property value, as an instance of the appropriate subclass of DataValue, or nil if the property value is nil or if the property value was not previously set.

  • Get the required value of a specified property path.

    Throws

    UndefinedException if the property value was not previously set (or is nil), CastException if the property value is nil.

    Declaration

    Swift

    public final func requiredValue(for path: PropertyPath) -> DataValue

    Parameters

    path

    The specified property path.

    Return Value

    The property value, using the appropriate subclass of DataValue.

  • Resolve dataPath for this structure’s child structures.

    Declaration

    Swift

    open func resolveChildPaths()
  • Resolve dataPath for this structure. It might still be null afterwards if it cannot be resolved.

    Declaration

    Swift

    open func resolveDataPath()
  • Resolve dataPath for this structure and its child structures.

    Declaration

    Swift

    open func resolveDataPaths()
  • Declaration

    Swift

    open func searchWords(select: PropertyList? = nil, tabs: Bool = true) -> StringList

    Parameters

    select

    Selected list of properties (can refer to properties of nested structure types). If nil, then all string-typed properties will be selected.

    tabs

    Should a tab be added between the words for separate properties, to prevent SearchTerm.phrase searches from matching phrases with words from different properties. Defaults to true.

    Return Value

    The candidate search words in this structure, for use by SearchExpression.matches. Search words are obtained from string-typed properties using SearchExpression.wordsInText.

  • Set the value of a specified property.

    Throws

    CastException if the property value does not have the expected type.

    Declaration

    Swift

    public final func setDataValue(for property: Property, to value: DataValue?)

    Parameters

    property

    The specified property.

    value

    The property value (or nil), using the appropriate subclass of DataValue.

  • Recursively apply default values to any unset properties of this structure. If a property has a model-defined default value, it will always be applied (since that default value is part of a server’s contract with the client, it must always be valid to apply it). If the property doesn’t have a model-defined default value, then nil will be used for nullable properties, and false/empty/zero values will be applied otherwise as appropriate. Dates will default to 2000-01-01.

    Declaration

    Swift

    public final func setDefaultValues(nestedComplex: Bool = true, nestedEntity: Bool = false, defaultOptional: Bool = true, defaultRequired: Bool = true, skipConstraints: Bool = false)

    Parameters

    nestedComplex

    Apply recursively to complex-typed (structural) properties of this structure? Defaults to true.

    nestedEntity

    Apply recursively to entity-typed (navigation) properties of this structure? Defaults to false.

    defaultOptional

    Apply non-model-defined default values to optional (nullable) properties? Defaults to true.

    defaultRequired

    Apply non-model-defined default values to required (non-nullable) properties? Defaults to true.

    skipConstraints

    Avoid applying default values to properties which have a database-level default constraint. Defaults to false.

  • Add or change the value of a dynamic property.

    See also

    dynamicProperties.

    Declaration

    Swift

    public final func setDynamicValue(name: String, value: DataValue?)

    Parameters

    name

    Name of a dynamic property.

    value

    Value for the dynamic property.

  • Set the optional value of a specified property. If a nil value is provided and the property does not permit nil values (Property.isNullable is false), then this is equivalent to calling unsetDataValue, otherwise it is equivalent to calling setDataValue.

    Throws

    CastException if the property value does not have the expected type.

    Declaration

    Swift

    public final func setOptionalValue(for property: Property, to value: DataValue?)

    Parameters

    property

    The specified property.

    value

    The property value (or nil), using the appropriate subclass of DataValue.

  • Set the required value of a specified property.

    Throws

    CastException if the property value does not have the expected type.

    Declaration

    Swift

    public final func setRequiredValue(for property: Property, to value: DataValue)

    Parameters

    property

    The specified property.

    value

    The property value, using the appropriate subclass of DataValue.

  • Set the value of a specified property (like setDataValue), but bypassing the usual validation checks. This may be useful in performance critical code, but note that it will be assumed that:

    • The property belongs to the structure’s type.
    • The value has the correct type for the property.

    Declaration

    Swift

    public final func setUnsafeValue(for property: Property, to value: DataValue?)

    Parameters

    property

    The specified property.

    value

    The property value (or nil), using the appropriate subclass of DataValue.

  • Get the stream link for a specified stream property.

    Throws

    UsageException if the property is not a stream property.

    Declaration

    Swift

    public final func streamLink(for property: Property) -> StreamLink

    Parameters

    property

    The specified stream property.

    Return Value

    The stream link.

  • The complex/entity type metadata for this value (dataType cast to StructureType).

    Declaration

    Swift

    open var structureType: StructureType { get }
  • Unset the value of a specified property, so that hasDataValue(property) will return false.

    Declaration

    Swift

    public final func unsetDataValue(for property: Property)

    Parameters

    property

    The specified property.

  • The canonical path of this value relative to the service root URL. Used internally in URL construction. Should not be set explicitly.

    Declaration

    Swift

    public final var valuePath: String? { get set }
  • Perform some work while holding an instance-level exclusive lock (if this structure is lock-enabled), or without a lock if this structure is not lock-enabled.

    Declaration

    Swift

    public final func withLock(work: @escaping () throws -> Void)

    Parameters

    work

    Work to be executed.