EnumType
open class EnumType : DataType, @unchecked Sendable
Encapsulates the metadata of an OData enum type.
-
Can this model element be removed by
DataService.refreshMetadata
. Defaults tofalse
. Set this totrue
to indicate that the application is coded to be able able to function correctly without this model element.See also
isRemoved
.Declaration
Swift
final public var canBeRemoved: Bool
-
Has this model element been removed by a successful call to
DataService.refreshMetadata
? IfisRemoved
== true, that implies that the old metadata (before refreshMetadata was called) did include this model element, and that the new metadata (after refreshMetadata was called) does not include this model element.See also
canBeRemoved
.Declaration
Swift
final public var isRemoved: Bool
-
Represents an undefined enum type.
Declaration
Swift
public static let undefined: EnumType
-
The local name of this type within its owning
DataSchema
, e.g. “MyType”.Declaration
Swift
final public var localName: String
-
The name of this type qualified by its owning
DataSchema
name, e.g. “MySchema.MyType”.Declaration
Swift
final public var qualifiedName: String
-
Source line number for this schema element within its defining schema.
Declaration
Swift
final public var sourceLine: Int
-
True if this type was added since metadata was originally loaded.
Declaration
Swift
final public var isExtension: Bool
-
true
if this simple type was inferred due to a missing term definition in the CSDL.Declaration
Swift
final public var isInferred: Bool
-
Does this enum type represent a set of bit flags?
Declaration
Swift
final public var isFlags: Bool
-
Is this type for client-only use in an offline scenario?
Declaration
Swift
final public var isClientOnly: Bool
-
true
if this is an open type. An open type can have dynamic members.Declaration
Swift
final public var isOpenType: Bool
-
If
isOpenType
is true, then the corresponding simple type (with Validation.AllowedValues annotation). Otherwisenil
.Declaration
Swift
final public var simpleType: SimpleType?
-
Default initializer.
Declaration
Swift
override public init()
-
Lookup an existing annotation by term name, or throw an exception if the annotation is not found.
Declaration
Swift
open func annotation(withName term: String) -> Annotation
Parameters
term
The term name.
Return Value
The annotation.
-
Obsolete. Use
annotations
.Declaration
Swift
open var annotationList: AnnotationList { get }
-
Obsolete. Use
annotations
.Declaration
Swift
open var annotationMap: AnnotationMap { get }
-
Map of annotations for this model element. For annotations without qualifiers, the entry key is the annotation term name. For annotations with qualifiers, the entry key is the annotation term name, then “#”, then the annotation qualifier.
Declaration
Swift
open var annotations: AnnotationMap { get }
-
DataType.ENUM_VALUE
.Declaration
Swift
override open var code: Int { get }
-
Synonym for
baseType
.Declaration
Swift
open var derivedFrom: DataType { get set }
-
Declaration
Swift
open func dynamicList(source: ListBase) -> DataValueList
Parameters
source
a list containing
ByteValue
,ShortValue
,IntValue
,LongValue
,UnsignedByte
orUnsignedShort
items (or nulls).Return Value
A list containing
EnumValue
instances corresponding to the numbers insource
. -
Lookup a member by name.
Declaration
Swift
open func findMember(name: String) -> EnumValue?
Parameters
name
Name of the member, or numeric value.
Return Value
The member value, or
nil
if not found. -
true
if this type is a derived simple, complex, entity or enum type.Declaration
Swift
override open var isDerived: Bool { get }
-
Lookup a member by name.
Throws
UndefinedException
if no member is found with this name.Declaration
Swift
open func member(name: String) -> EnumValue
Parameters
name
Name of the member, or numeric value.
Return Value
The member value.
-
List of members for this type.
Declaration
Swift
public final var memberList: EnumValueList { get set }
-
Map of members for this type.
Declaration
Swift
public final var memberMap: EnumValueMap { get set }
-
Synonym for
qualifiedName
.Declaration
Swift
override open var name: String { get }
-
Create a new open enum type, or return a cached enum type, based on an existing simple type. The supported kind of simple type is an OData TypeDefinition using Core.SymbolicName and Validation.AllowedValue to define member names and values. The named values should be integer values (byte, short, int, long) or strings.
Declaration
Swift
open class func openSimple(type: SimpleType, terms: AnnotationTermMap? = nil, cache: Bool = true) -> EnumType
Parameters
type
Simple type.
terms
Annotation terms from parsed metadata document (
CsdlDocument.annotationTerms
). Provide only if the type’s members will be edited (e.g. by metadata tools).cache
Allow caching and reuse of the returned enum type for this simple type. Defaults to
true
.Return Value
Enum type, or
EnumType.undefined
if this simple type is not definied according to the requirements of an open enumeration. -
Declaration
Swift
override open func toString() -> String
Return Value
The name of this data type.
-
Declaration
Swift
open func withByte(_ value: Int) -> EnumValue
Parameters
value
Numeric enum value.
Return Value
A value of this enum type with the specified value.
-
Declaration
Swift
open func withInt(_ value: Int) -> EnumValue
Parameters
value
Numeric enum value.
Return Value
A value of this enum type with the specified value.
-
Declaration
Swift
open func withLong(_ value: Int64) -> EnumValue
Parameters
value
Numeric enum value.
Return Value
A value of this enum type with the specified value.
-
Declaration
Swift
open func withNumberOrNull(_ value: Int64) -> EnumValue?
Parameters
value
Eenum value expressed as a number.
Return Value
A value of this enum type with the specified number value, or
nil
if there is no such member. -
Declaration
Swift
open func withOptionalByte(_ value: Int?) -> EnumValue?
Parameters
value
Numeric enum value.
Return Value
A value of this enum type with the specified value.
-
Declaration
Swift
open func withOptionalInt(_ value: Int?) -> EnumValue?
Parameters
value
Numeric enum value.
Return Value
A value of this enum type with the specified value.
-
Declaration
Swift
open func withOptionalLong(_ value: Int64?) -> EnumValue?
Parameters
value
Numeric enum value.
Return Value
A value of this enum type with the specified value.
-
Declaration
Swift
open func withOptionalShort(_ value: Int?) -> EnumValue?
Parameters
value
Numeric enum value.
Return Value
A value of this enum type with the specified value.
-
Declaration
Swift
open func withShort(_ value: Int) -> EnumValue
Parameters
value
Numeric enum value.
Return Value
A value of this enum type with the specified value.
-
Declaration
Swift
open func withStringOrNull(_ value: String) -> EnumValue?
Parameters
value
Eenum value expressed as a string.
Return Value
A value of this enum type with the specified string value, or
nil
if there is no such member. -
Declaration
Swift
open func withUnsignedByte(_ value: UnsignedByte?) -> EnumValue?
Parameters
value
Numeric enum value.
Return Value
A value of this enum type with the specified value.
-
Declaration
Swift
open func withUnsignedShort(_ value: UnsignedShort?) -> EnumValue?
Parameters
value
Numeric enum value.
Return Value
A value of this enum type with the specified value.