AbstractIdentifierNamesGenerator.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { inject, injectable } from 'inversify';
  2. import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
  3. import { IIdentifierNamesGenerator } from '../../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
  4. import { IOptions } from '../../interfaces/options/IOptions';
  5. import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
  6. @injectable()
  7. export abstract class AbstractIdentifierNamesGenerator implements IIdentifierNamesGenerator {
  8. /**
  9. * @type {IOptions}
  10. */
  11. protected readonly options: IOptions;
  12. /**
  13. * @type {IRandomGenerator}
  14. */
  15. protected readonly randomGenerator: IRandomGenerator;
  16. /**
  17. * @param {IRandomGenerator} randomGenerator
  18. * @param {IOptions} options
  19. */
  20. constructor (
  21. @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
  22. @inject(ServiceIdentifiers.IOptions) options: IOptions
  23. ) {
  24. this.randomGenerator = randomGenerator;
  25. this.options = options;
  26. }
  27. /**
  28. * @param {number} length
  29. * @returns {string}
  30. */
  31. public abstract generate (length: number): string;
  32. }