StructureBase
open class StructureBase: DataValue, Codable
The canonical path of this value relative to the service root URL.
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()
-
Get the value of a specified property.
Throws
UndefinedException
if the property value was not previously set.See also
hasDataValue
.Parameters
property
The specified property.
Return Value
The property value, as an instance of the appropriate subclass of
DataValue
, ornil
if the property value isnil
. -
Holds dynamic property values, for which metadata is not known in advance.
See also
ComplexType.isOpenType
,EntityType.isOpenType
.Declaration
Swift
open var dynamicProperties: DataValueMap
-
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 datatype
(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 (includingnil
, ifProperty.isNullable
). -
Is this structure an instance of a generated proxy class?
Declaration
Swift
open var isProxy: Bool
-
Get the optional value of a specified property.
Parameters
property
The specified property.
Return Value
The property value, as an instance of the appropriate subclass of
DataValue
, ornil
if the property value isnil
or if the property value was not previously set. -
Get the required value of a specified property.
Throws
UndefinedException
if the property value was not previously set,CastException
if the property value isnil
.Parameters
property
The specified property.
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.Parameters
property
The specified property.
value
The property value (or
nil
), using the appropriate subclass ofDataValue
. -
Recursively apply default values to any unset properties of this structure. 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.See also
hasDataValue
,Property.defaultValue
,StructureType.structuralProperties
,StructureType.navigationProperties
.Declaration
Swift
open func setDefaultValues(nestedComplex: Bool = true, nestedEntity: Bool = false, overwrite: Bool = false) -> Void
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.
overwrite
Overwrite the property value even if it is already set.
-
Add or change the value of a dynamic property.
See also
dynamicProperties
.Declaration
Swift
open func setDynamicValue(name: String, value: DataValue?) -> Void
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 permitnil
values (Property.isNullable
isfalse
), then this is equivalent to callingunsetDataValue
, otherwise it is equivalent to callingsetDataValue
.Throws
CastException
if the property value does not have the expected type.Parameters
property
The specified property.
value
The property value (or
nil
), using the appropriate subclass ofDataValue
. -
Set the required value of a specified property.
Throws
CastException
if the property value does not have the expected type.Parameters
property
The specified property.
value
The property value, 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 toStructureType
).Declaration
Swift
open var structureType: StructureType
-
Unset the value of a specified property, so that
hasDataValue
(property)
will returnfalse
.Declaration
Swift
open func unsetDataValue(for property: Property) -> Void
Parameters
property
The specified property.