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) throwsParameters
fromdecoder 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) throwsParameters
toencoder 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 } -
See also
ComplexValue.copyComplex,EntityValue.copyEntity.Declaration
Swift
open func copyStructure() -> StructureBaseReturn Value
A copy of this structure (only structural properties are copied).
-
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
UndefinedExceptionif the property value was not previously set.See also
hasDataValue.Declaration
Swift
public final func dataValue(for path: PropertyPath) -> DataValue?Parameters
pathThe specified property path.
Return Value
The property value, as an instance of the appropriate subclass of
DataValue, ornilif the property value isnil. -
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
nameName of a dynamic property.
Return Value
The value of a dynamic property, or
nilif no such property exists. -
Declaration
Swift
open func hasChangedProperties() -> BoolReturn Value
trueif this structure has one or more changed properties. SeeeComplexValue.oldComplex,EntityValue.oldEntity. -
Declaration
Swift
public final func hasDataType(_ type: DataType) -> BoolParameters
typeSpecified data type.
Return Value
trueif this structure has the specified datatype(or a subtype). -
Declaration
Swift
public final func hasDataValue(for property: Property) -> BoolParameters
propertyThe specified property.
Return Value
trueif this structure contains an explicitly set value for the specified property (includingnil, ifProperty.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) -> BoolParameters
propertyThe specified property.
Return Value
trueif this structure contains a next-link for the specified collection-typed property. -
Declaration
Swift
open func isNewOrChanged(property: Property) -> BoolParameters
propertyStructural property.
Return Value
trueif the value of propertypropertyis 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
pathThe specified property path.
Return Value
The next-link, or
nilif there is no next link for the specified path. -
Contains the original values for all structural properties of this structure. See
ComplexValue.oldComplex,EntityValue.oldEntity.Declaration
Swift
public final var oldStructure: StructureBase? { get set } -
Get the optional value of a specified property path.
Declaration
Swift
public final func optionalValue(for path: PropertyPath) -> DataValue?Parameters
pathThe specified property path.
Return Value
The property value, as an instance of the appropriate subclass of
DataValue, ornilif the property value isnilor if the property value was not previously set. -
Get the required value of a specified property path.
Throws
UndefinedExceptionif the property value was not previously set (or isnil),CastExceptionif the property value isnil.Declaration
Swift
public final func requiredValue(for path: PropertyPath) -> DataValueParameters
pathThe specified property path.
Return Value
The property value, using the appropriate subclass of
DataValue. -
Resolve
dataPathfor this structure’s child structures.Declaration
Swift
open func resolveChildPaths() -
Resolve
dataPathfor this structure. It might still be null afterwards if it cannot be resolved.Declaration
Swift
open func resolveDataPath() -
Resolve
dataPathfor this structure and its child structures.Declaration
Swift
open func resolveDataPaths() -
Declaration
Swift
open func searchWords(select: PropertyList? = nil, tabs: Bool = true) -> StringListParameters
selectSelected list of properties (can refer to properties of nested structure types). If
nil, then all string-typed properties will be selected.tabsShould a tab be added between the words for separate properties, to prevent
SearchTerm.phrasesearches from matching phrases with words from different properties. Defaults totrue.Return Value
The candidate search words in this structure, for use by
SearchExpression.matches. Search words are obtained from string-typed properties usingSearchExpression.wordsInText. -
Set the value of a specified property.
Throws
CastExceptionif the property value does not have the expected type.Parameters
propertyThe specified property.
valueThe property value (or
nil), using the appropriate subclass ofDataValue. -
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
nilwill be used for nullable properties, and false/empty/zero values will be applied otherwise as appropriate. Dates will default to 2000-01-01.See also
hasDataValue,Property.defaultValue,StructureType.structuralProperties,StructureType.navigationProperties.Declaration
Swift
public final func setDefaultValues(nestedComplex: Bool = true, nestedEntity: Bool = false, defaultOptional: Bool = true, defaultRequired: Bool = true, skipConstraints: Bool = false)Parameters
nestedComplexApply recursively to complex-typed (structural) properties of this structure? Defaults to true.
nestedEntityApply recursively to entity-typed (navigation) properties of this structure? Defaults to false.
defaultOptionalApply non-model-defined default values to optional (nullable) properties? Defaults to true.
defaultRequiredApply non-model-defined default values to required (non-nullable) properties? Defaults to true.
skipConstraintsAvoid 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
nameName of a dynamic property.
valueValue for the dynamic property.
-
Set the optional value of a specified property. If a
nilvalue is provided and the property does not permitnilvalues (Property.isNullableisfalse), then this is equivalent to callingunsetDataValue, otherwise it is equivalent to callingsetDataValue.Throws
CastExceptionif the property value does not have the expected type.Parameters
propertyThe specified property.
valueThe property value (or
nil), using the appropriate subclass ofDataValue. -
Set the required value of a specified property.
Throws
CastExceptionif the property value does not have the expected type.Parameters
propertyThe specified property.
valueThe 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.
Parameters
propertyThe specified property.
valueThe property value (or
nil), using the appropriate subclass ofDataValue. -
Get the stream link for a specified stream property.
Throws
UsageExceptionif the property is not a stream property.Declaration
Swift
public final func streamLink(for property: Property) -> StreamLinkParameters
propertyThe specified stream property.
Return Value
The stream link.
-
The complex/entity type metadata for this value (
dataTypecast toStructureType).Declaration
Swift
open var structureType: StructureType { get } -
Unset the value of a specified property, so that
hasDataValue(property)will returnfalse.Declaration
Swift
public final func unsetDataValue(for property: Property)Parameters
propertyThe 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
workwhile 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
workWork to be executed.