StructureBase

open class StructureBase : DataValue, Codable

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

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

    Declaration

    Swift

    final public var annotations: AnnotationMap
  • Default initializer.

    Declaration

    Swift

    override public init()
  • Get the value of a specified property path.

    Throws

    UndefinedException if the property value was not previously set.

    See also

    hasDataValue.

    Declaration

    Swift

    open 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

    open var dynamicProperties: DataValueMap { get set }
  • See also

    dynamicProperties.

    Declaration

    Swift

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

    open 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

    open var hasDynamicProperties: Bool { get }
  • Declaration

    Swift

    open 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.

  • 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

    open 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

    open 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

    open func requiredValue(for path: PropertyPath) -> DataValue

    Parameters

    path

    The specified property path.

    Return Value

    The property value, using the appropriate subclass of DataValue.

  • Set the value of a specified property.

    Throws

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

    Declaration

    Swift

    open 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?

    defaultRequired

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

    skipConstraints

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

  • Add or change the value of a dynamic property.

    See also

    dynamicProperties.

    Declaration

    Swift

    open 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

    open 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

    open 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

    open 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

    open 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

    open 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 }