ENMKlasse.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import { JavaObject, cast_java_lang_Object } from '../../../java/lang/JavaObject';
  2. import { JavaLong, cast_java_lang_Long } from '../../../java/lang/JavaLong';
  3. import { JavaString, cast_java_lang_String } from '../../../java/lang/JavaString';
  4. import { Vector, cast_java_util_Vector } from '../../../java/util/Vector';
  5. export class ENMKlasse extends JavaObject {
  6. public id : number = 0;
  7. public kuerzel : String | null = null;
  8. public kuerzelAnzeige : String | null = null;
  9. public sortierung : number = 0;
  10. public klassenlehrer : Vector<Number> = new Vector();
  11. public constructor() {
  12. super();
  13. }
  14. isTranspiledInstanceOf(name : string): boolean {
  15. return ['de.nrw.schule.svws.core.data.enm.ENMKlasse'].includes(name);
  16. }
  17. public static transpilerFromJSON(json : string): ENMKlasse {
  18. const obj = JSON.parse(json);
  19. const result = new ENMKlasse();
  20. if (typeof obj.id === "undefined")
  21. throw new Error('invalid json format, missing attribute id');
  22. result.id = obj.id;
  23. result.kuerzel = typeof obj.kuerzel === "undefined" ? null : obj.kuerzel;
  24. result.kuerzelAnzeige = typeof obj.kuerzelAnzeige === "undefined" ? null : obj.kuerzelAnzeige;
  25. if (typeof obj.sortierung === "undefined")
  26. throw new Error('invalid json format, missing attribute sortierung');
  27. result.sortierung = obj.sortierung;
  28. if (!!obj.klassenlehrer) {
  29. for (let elem of obj.klassenlehrer) {
  30. result.klassenlehrer?.add(elem);
  31. }
  32. }
  33. return result;
  34. }
  35. public static transpilerToJSON(obj : ENMKlasse) : string {
  36. let result = '{';
  37. result += '"id" : ' + obj.id + ',';
  38. result += '"kuerzel" : ' + ((!obj.kuerzel) ? 'null' : '"' + obj.kuerzel.valueOf() + '"') + ',';
  39. result += '"kuerzelAnzeige" : ' + ((!obj.kuerzelAnzeige) ? 'null' : '"' + obj.kuerzelAnzeige.valueOf() + '"') + ',';
  40. result += '"sortierung" : ' + obj.sortierung + ',';
  41. if (!obj.klassenlehrer) {
  42. result += '[]';
  43. } else {
  44. result += '[ ';
  45. for (let i : number = 0; i < obj.klassenlehrer.size(); i++) {
  46. let elem = obj.klassenlehrer.get(i);
  47. result += elem;
  48. if (i < obj.klassenlehrer.size() - 1)
  49. result += ',';
  50. }
  51. result += ' ]' + ',';
  52. }
  53. result = result.slice(0, -1);
  54. result += '}';
  55. return result;
  56. }
  57. public static transpilerToJSONPatch(obj : Partial<ENMKlasse>) : string {
  58. let result = '{';
  59. if (typeof obj.id !== "undefined") {
  60. result += '"id" : ' + obj.id + ',';
  61. }
  62. if (typeof obj.kuerzel !== "undefined") {
  63. result += '"kuerzel" : ' + ((!obj.kuerzel) ? 'null' : '"' + obj.kuerzel.valueOf() + '"') + ',';
  64. }
  65. if (typeof obj.kuerzelAnzeige !== "undefined") {
  66. result += '"kuerzelAnzeige" : ' + ((!obj.kuerzelAnzeige) ? 'null' : '"' + obj.kuerzelAnzeige.valueOf() + '"') + ',';
  67. }
  68. if (typeof obj.sortierung !== "undefined") {
  69. result += '"sortierung" : ' + obj.sortierung + ',';
  70. }
  71. if (typeof obj.klassenlehrer !== "undefined") {
  72. if (!obj.klassenlehrer) {
  73. result += '[]';
  74. } else {
  75. result += '[ ';
  76. for (let i : number = 0; i < obj.klassenlehrer.size(); i++) {
  77. let elem = obj.klassenlehrer.get(i);
  78. result += elem;
  79. if (i < obj.klassenlehrer.size() - 1)
  80. result += ',';
  81. }
  82. result += ' ]' + ',';
  83. }
  84. }
  85. result = result.slice(0, -1);
  86. result += '}';
  87. return result;
  88. }
  89. }
  90. export function cast_de_nrw_schule_svws_core_data_enm_ENMKlasse(obj : unknown) : ENMKlasse {
  91. return obj as ENMKlasse;
  92. }