Bona Iqiniso Application Board

V3BiStakeholderArray

Specification for V3BiStakeholderArray

Attributes

AttributeTypeDescription
itemsV3BiStakeholderBase[]Array of stakeholder base objects

Methods

MethodDescription
constructorInitializes a new instance of V3BiStakeholderArray with the provided items array.
getStakeholderReturns the V3BiStakeholderBase object matching the provided reference, or undefined if no match is found.
getStakeholderByLanguageReturns 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

ScenarioGivenWhenThen
Create an instance with all attributesThe items is a valid array of V3BiStakeholderBase objectsI create a new V3BiStakeholderArray with itemsThe instance should be created with the specified items array
Return the correct stakeholder for a valid referenceThe 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 referenceThe 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 languageThe items contains a V3BiStakeholderBase with reference as 'stakeholder1' and language 'en' existsI call getStakeholderByLanguage with 'stakeholder1' and 'en'The correct stakeholder description in English should be returned
Return “unknown stakeholder description” for non-existent languageThe 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 referenceThe 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

AttributeTypeDescription
itemsV3BiStakeholderBase[]Array of stakeholder base objects
MethodDescription
constructorInitializes a new instance of V3BiStakeholderArray with the provided items array.
getStakeholderReturns the V3BiStakeholderBase object matching the provided reference, or undefined if no match is found.
getStakeholderByLanguageReturns 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.