Specification for V3BiStakeholderArray
Attributes
| Attribute | Type | Description |
|---|---|---|
items | V3BiStakeholderBase[] | Array of stakeholder base objects |
Methods
| Method | Description |
|---|---|
constructor | Initializes a new instance of V3BiStakeholderArray with the provided items array. |
getStakeholder | Returns the V3BiStakeholderBase object matching the provided reference, or undefined if no match is found. |
getStakeholderByLanguage | Returns the stakeholder description in the specified language, or ‘undefined stakeholder’ if not found. |
Constructor
Signature:
constructor(items: V3BiStakeholderBase[])
Parameters:
items(V3BiStakeholderBase[]): Array of stakeholder base objects.
Description:
The constructor initializes the V3BiStakeholderArray instance with the provided items array.
Method: getStakeholder
Signature:
getStakeholder(reference: string): V3BiStakeholderBase | undefined
Parameters:
reference(string): The unique identifier for the stakeholder to be retrieved.
Description:
Returns the V3BiStakeholderBase object that matches the provided reference, or undefined if no match is found.
Method: getStakeholderByLanguage
Signature:
getStakeholderByLanguage(reference: string, language: string): string | "undefined stakeholder"
Parameters:
reference(string): The unique identifier for the stakeholder.language(string): The language code for which the stakeholder description is requested.
Description:
Returns the stakeholder description in the specified language, or ‘undefined stakeholder’ if the reference does not exist.
Example Usage
const stakeholders = [
new V3BiStakeholderBase('stakeholder1', [new V3BiTranslationBase('en', 'Description 1')]),
new V3BiStakeholderBase('stakeholder2', [new V3BiTranslationBase('es', 'Descripción 2')])
];
const stakeholderArray = new V3BiStakeholderArray(stakeholders);
console.log(stakeholderArray.getStakeholder('stakeholder1')); // Output: V3BiStakeholderBase object for stakeholder1
console.log(stakeholderArray.getStakeholderByLanguage('stakeholder1', 'en')); // Output: Description 1
console.log(stakeholderArray.getStakeholderByLanguage('stakeholder1', 'fr')); // Output: unknown stakeholder description
console.log(stakeholderArray.getStakeholderByLanguage('stakeholder3', 'en')); // Output: undefined stakeholder
Scenario Table
| Scenario | Given | When | Then |
|---|---|---|---|
| Create an instance with all attributes | The items is a valid array of V3BiStakeholderBase objects | I create a new V3BiStakeholderArray with items | The instance should be created with the specified items array |
| Return the correct stakeholder for a valid reference | The items contains a V3BiStakeholderBase with reference as 'stakeholder1' | I call getStakeholder with 'stakeholder1' | The V3BiStakeholderBase object with reference 'stakeholder1' should be returned |
| Return undefined for a non-existent reference | The items does not contain a V3BiStakeholderBase with reference as 'stakeholder3' | I call getStakeholder with 'stakeholder3' | The result should be undefined |
| Return the correct stakeholder description by language | The items contains a V3BiStakeholderBase with reference as 'stakeholder1' and language 'en' exists | I call getStakeholderByLanguage with 'stakeholder1' and 'en' | The correct stakeholder description in English should be returned |
| Return “unknown stakeholder description” for non-existent language | The items contains a V3BiStakeholderBase with reference as 'stakeholder1' but does not have language 'fr' | I call getStakeholderByLanguage with 'stakeholder1' and 'fr' | The result should be 'unknown stakeholder description' |
| Return “undefined stakeholder” for non-existent reference | The items does not contain a V3BiStakeholderBase with reference as 'stakeholder3' | I call getStakeholderByLanguage with 'stakeholder3' and 'en' | The result should be 'undefined stakeholder' |
Overview Table
| Attribute | Type | Description |
|---|---|---|
items | V3BiStakeholderBase[] | Array of stakeholder base objects |
| Method | Description |
|---|---|
constructor | Initializes a new instance of V3BiStakeholderArray with the provided items array. |
getStakeholder | Returns the V3BiStakeholderBase object matching the provided reference, or undefined if no match is found. |
getStakeholderByLanguage | Returns the stakeholder description in the specified language, or ‘undefined stakeholder’ if not found. |
This setup ensures that the V3BiStakeholderArray class is correctly instantiated and that its methods function as expected under various scenarios.