GostBlockungRegel.ts 2.4 KB

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