Skip to main content

IModel.SetFieldAt method

Namespace: NextDesign.Core

Description

Sets the specified value at the specified index position of the specified field of this instance.
An exception is thrown if a value is specified that cannot be set for the specified field.
Note that no exception is thrown even if the field multiplicity upper bound constraint or path constraint is violated.

argument

NameTypeDescription
fieldNamestringField name
You cannot specify null or an empty string.
valueobjectfield value
indexintPosition
Specifies the index starting at 0.

Return value

  • void

Exceptions

NameException ClassDescription
Invalid argumentExtensionArgumentExceptionIf null or an empty string is specified for fieldName
Field not foundExtensionFieldNotFoundExceptionIf the specified field is not found in this instance's metaclass
Illegal field accessExtensionIllegalFieldAccessExceptionIf this method is executed for a field with a maximum multiplicity of 1
Invalid index rangeExtensionOutOfRangeExceptionWhen a negative number is specified for index
or when a value greater than the number of elements in the corresponding field is specified for index
ExtensionInvalidTypeExceptionWhen a value that cannot be set in the specified field is specified for the value that does not match the type of the field.
- A primitive type value or an enumeration value is specified in a class type field.
- Incompatible class type specified
Illegal operationExtensionInvalidOperationExceptionIf the model itself is a deleted model or a temporary proxy
If an inoperable field is specified in the field name
- Product line feature assignment field
- System. Fields tagged with Core
Circular referenceExtensionCircularReferenceExceptionWhen the argument value specifies the invocation target of this method or its ancestors when invoking an owned field of a class type
ExtensionInvalidModelException with invalid model specified

Annotations

Values that can be set depending on the field type

The values that can be set depend on the field type as follows.

  • Primitive type fields (integer, real, boolean, string, rich text)

    It cannot be set by this method.

  • enum field

    It cannot be set by this method.

  • Class type field

    Fields of class types can set instances of the IModel interface and null.

    If a value of type IModel is specified, sets the specified model instead of the model that was already set.
    At this time, the behavior differs depending on whether the field is owned or referenced.

    • If owned, moves the model specified in the argument as a child of the method caller's model. It also removes the model that was already set.
    • For references, add a reference relationship with the model specified by the argument. Also, delete the existing reference relationship with the model that was already set. The model itself, which has already been set, is not deleted.

    If null is specified, it will only unset models that have already been set.

    • If owned, delete the already set model.
    • In case of reference, delete the existing reference relationship with the model that was already set. The model itself, which has already been set, is not deleted.

    If null is specified, the specified element is removed and subsequent elements are shifted forward.