LogLevel.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import { JavaObject, cast_java_lang_Object } from '../java/lang/JavaObject';
  2. export class LogLevel extends JavaObject {
  3. /** the name of the enumeration value */
  4. private readonly __name : String;
  5. /** the ordinal value for the enumeration value */
  6. private readonly __ordinal : number;
  7. /** an array containing all values of this enumeration */
  8. private static readonly all_values_by_ordinal : Array<LogLevel> = [];
  9. /** an array containing all values of this enumeration indexed by their name*/
  10. private static readonly all_values_by_name : Map<String, LogLevel> = new Map<String, LogLevel>();
  11. public static readonly APP : LogLevel = new LogLevel("APP", 0, 0);
  12. public static readonly ERROR : LogLevel = new LogLevel("ERROR", 1, 10);
  13. public static readonly WARNING : LogLevel = new LogLevel("WARNING", 2, 100);
  14. public static readonly INFO : LogLevel = new LogLevel("INFO", 3, 1000);
  15. public static readonly DEBUG : LogLevel = new LogLevel("DEBUG", 4, 10000);
  16. private readonly level : number;
  17. /**
  18. * Der von der Ausfzählung intern genutzte Konstruktor der Aufzählung
  19. *
  20. * @param level der Integer-Wert des Log-Levels.
  21. */
  22. private constructor(name : string, ordinal : number, level : number) {
  23. super();
  24. this.__name = name;
  25. this.__ordinal = ordinal;
  26. LogLevel.all_values_by_ordinal.push(this);
  27. LogLevel.all_values_by_name.set(name, this);
  28. this.level = level;
  29. }
  30. /**
  31. * Gibt den Integer-Wert des Log-Levels zurück.
  32. *
  33. * @return der Integer-Wert des Log-Levels
  34. */
  35. public toInteger() : number {
  36. return this.level;
  37. }
  38. /**
  39. * Returns the name of this enumeration value.
  40. *
  41. * @returns the name
  42. */
  43. private name() : String {
  44. return this.__name;
  45. }
  46. /**
  47. * Returns the ordinal value of this enumeration value.
  48. *
  49. * @returns the ordinal value
  50. */
  51. private ordinal() : number {
  52. return this.__ordinal;
  53. }
  54. /**
  55. * Returns the name of this enumeration value.
  56. *
  57. * @returns the name
  58. */
  59. public toString() : String {
  60. return this.__name;
  61. }
  62. /**
  63. * Returns true if this and the other enumeration values are equal.
  64. *
  65. * @param other the other enumeration value
  66. *
  67. * @returns true if they are equal and false otherwise
  68. */
  69. public equals(other : JavaObject) : boolean {
  70. if (!(other instanceof LogLevel))
  71. return false;
  72. return this === other;
  73. }
  74. /**
  75. * Returns the ordinal value as hashcode, since the ordinal value is unique.
  76. *
  77. * @returns the ordinal value as hashcode
  78. */
  79. public hashCode() : number {
  80. return this.__ordinal;
  81. }
  82. /**
  83. * Compares this enumeration value with the other enumeration value by their ordinal value.
  84. *
  85. * @param other the other enumeration value
  86. *
  87. * @returns a negative, zero or postive value as this enumeration value is less than, equal to
  88. * or greater than the other enumeration value
  89. */
  90. public compareTo(other : LogLevel) : number {
  91. return this.__ordinal - other.__ordinal;
  92. }
  93. /**
  94. * Returns an array with enumeration values.
  95. *
  96. * @returns the array with enumeration values
  97. */
  98. public static values() : Array<LogLevel> {
  99. return [...this.all_values_by_ordinal];
  100. }
  101. /**
  102. * Returns the enumeration value with the specified name.
  103. *
  104. * @param name the name of the enumeration value
  105. *
  106. * @returns the enumeration values or null
  107. */
  108. public static valueOf(name : String) : LogLevel | null {
  109. let tmp : LogLevel | undefined = this.all_values_by_name.get(name);
  110. return (!tmp) ? null : tmp;
  111. }
  112. isTranspiledInstanceOf(name : string): boolean {
  113. return ['de.nrw.schule.svws.logger.LogLevel'].includes(name);
  114. }
  115. }
  116. export function cast_de_nrw_schule_svws_logger_LogLevel(obj : unknown) : LogLevel {
  117. return obj as LogLevel;
  118. }