getPluralForEntityName static method

String getPluralForEntityName(
  1. String entity
)

Returns the plural form of the given entity name.

The entity parameter is the name of the entity in singular form.

This method handles a predefined list of special cases where the plural form does not simply involve appending an 's' to the singular form. For all other entity names, this method returns the entity name with an 's' appended.

Implementation

static String getPluralForEntityName(String entity) {
  switch (entity) {
    case 'Beneficiary':
      return 'Beneficiaries';
    case 'ProjectBeneficiary':
      return 'ProjectBeneficiaries';
    case 'Address':
      return 'Addresses';
    case 'Facility':
      return 'Facilities';
    case 'ProjectFacility':
      return 'ProjectFacilities';
    case 'Project':
      return 'Projects';
    case 'Stock':
      return 'Stock';
    case 'StockReconciliation':
      return 'StockReconciliation';
    case 'User':
      return 'user';
    case 'AttendanceRegister':
      return 'attendanceRegister';
    case 'Attendance':
      return 'attendance';
    default:
      return '${entity}s';
  }
}