Skip to main content

IModel.SetFieldAt Method

Namespace: NextDesign.Core

Description

Sets the specified value to the specified index position of the specified field in this instance.
An exception is thrown if a value that cannot be set to the specified field is specified.
Note that no exception is thrown if the field's multiplicity limit constraint or path constraint is violated.

Argument

NameTypeDescription
fieldNamestringField name
Null or empty string cannot be specified.
valueobjectField value
indexintPosition
Specifies an index with the starting position being 0.

Return value

  • void

Exceptions

NameException ClassDescription
Invalid ArgumentExtensionArgumentExceptionWhen null or an empty string is specified for fieldName
Field Not FoundExtensionFieldNotFoundExceptionWhen the specified field is not found in this instance's metaclass
Invalid Field AccessExtensionIllegalFieldAccessExceptionWhen this method is executed on a field with a multiplicity limit of 1
Invalid Index RangeExtensionOutOfRangeExceptionWhen a negative number is specified for index
or when a value greater than or equal to the number of elements in the field is specified for index
Field Type IncompatibleExtensionInvalidTypeExceptionWhen a value that cannot be set for the specified field is specified for value
- A primitive type value or an enumeration value is specified for a class type field
- Incompatible class type specified
Invalid OperationExtensionInvalidOperationExceptionIf the model itself has been deleted or is a temporary proxy
If an unoperable field is specified as the field name
- Product line feature assignment field
- Field with the System.Core tag
If an invalid field is specified
Circular ReferenceExtensionCircularReferenceExceptionWhen calling on a field owned by a class type, if the argument value specifies the target of this method call or its ancestor
Invalid Model SpecifiedExtensionInvalidModelExceptionIf a deleted model or temporary proxy is specified as the field value

Annotation

Values ​​that can be set depending on the field type

The values ​​that can be set depending on the field type are determined as follows:

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

    Cannot be set with this method.

  • Enumeration type fields

    Cannot be set with this method.

  • Class Type Field

    A class type field can be set to an instance of the IModel interface or null.

    If an IModel value is specified, the specified model is set in place of the model that was already set.
    The behavior differs depending on whether the field is owned or referenced.

    • If owned, the model specified in the argument is moved as a child of the model that called the method. The model that was already set is also removed.

    • If referenced, a reference relationship is added between the model specified in the argument and the existing model. The existing reference relationship between the existing model and the existing model is also removed. The existing model itself is not removed.

    If null is specified, only the existing model is unset.

    • If owned, the existing model is removed.

    • If referenced, the existing reference relationship between the existing model and the existing model is removed. The existing model itself is not removed.

When null is specified, the element at the specified index is removed, and subsequent elements are shifted forward.