AVLMapSubEntrySet.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import { JavaMapEntry, cast_java_util_Map_Entry } from '../../../java/util/JavaMapEntry';
  2. import { JavaSet, cast_java_util_Set } from '../../../java/util/JavaSet';
  3. import { JavaIterator, cast_java_util_Iterator } from '../../../java/util/JavaIterator';
  4. import { Collection, cast_java_util_Collection } from '../../../java/util/Collection';
  5. import { JavaObject, cast_java_lang_Object } from '../../../java/lang/JavaObject';
  6. import { JavaString, cast_java_lang_String } from '../../../java/lang/JavaString';
  7. import { JavaMap, cast_java_util_Map } from '../../../java/util/JavaMap';
  8. import { AVLMapSubMap, cast_de_nrw_schule_svws_core_adt_map_AVLMapSubMap } from '../../../core/adt/map/AVLMapSubMap';
  9. export class AVLMapSubEntrySet<K, V> extends JavaObject implements JavaSet<JavaMapEntry<K, V>> {
  10. private readonly _sub : AVLMapSubMap<K, V>;
  11. /**
  12. * Erstellt ein neues SubEntrySet auf die übergebene {@link AVLMap}.
  13. *
  14. * @param sub Die {@link AVLMapSubMap} auf der operiert wird.
  15. */
  16. constructor(sub : AVLMapSubMap<K, V>) {
  17. super();
  18. this._sub = sub;
  19. }
  20. public toString() : String {
  21. return this._sub.toString();
  22. }
  23. public size() : number {
  24. return this._sub.size();
  25. }
  26. public isEmpty() : boolean {
  27. return this._sub.isEmpty();
  28. }
  29. public contains(o : unknown) : boolean {
  30. return this._sub.bcContainsEntry(o);
  31. }
  32. public iterator() : JavaIterator<JavaMapEntry<K, V>> {
  33. return this._sub.bcGetSubEntrySetIterator();
  34. }
  35. public toArray() : Array<unknown | null>;
  36. public toArray<T>(a : Array<T | null>) : Array<T | null>;
  37. /**
  38. * Implementation for method overloads of 'toArray'
  39. */
  40. public toArray<T>(__param0? : Array<T | null>) : Array<T | null> | Array<unknown | null> {
  41. if ((typeof __param0 === "undefined")) {
  42. return this._sub.bcGetArrayListOfEntries().toArray();
  43. } else if (((typeof __param0 !== "undefined") && Array.isArray(__param0))) {
  44. let a : Array<T | null> = __param0;
  45. return this._sub.bcGetArrayListOfEntries().toArray(a);
  46. } else throw new Error('invalid method overload');
  47. }
  48. public add(e : JavaMapEntry<K, V>) : boolean {
  49. return this._sub.bcAddEntryReturnBool(e);
  50. }
  51. public remove(o : unknown) : boolean {
  52. return this._sub.bcRemoveEntry(o);
  53. }
  54. public containsAll(c : Collection<unknown>) : boolean {
  55. return this._sub.bcContainsAllEntries(c);
  56. }
  57. public addAll(c : Collection<JavaMapEntry<K, V>>) : boolean {
  58. return this._sub.bcAddAllEntries(c);
  59. }
  60. public retainAll(c : Collection<unknown>) : boolean {
  61. return this._sub.bcRetainAllEntries(c);
  62. }
  63. public removeAll(c : Collection<unknown>) : boolean {
  64. return this._sub.bcRemoveAllEntries(c);
  65. }
  66. public clear() : void {
  67. this._sub.clear();
  68. }
  69. isTranspiledInstanceOf(name : string): boolean {
  70. return ['java.util.Collection', 'java.util.Set', 'java.lang.Iterable', 'de.nrw.schule.svws.core.adt.map.AVLMapSubEntrySet'].includes(name);
  71. }
  72. public [Symbol.iterator](): Iterator<JavaMapEntry<any, any>> {
  73. let iter : JavaIterator<JavaMapEntry<any, any>> = this.iterator();
  74. const result : Iterator<JavaMapEntry<any, any>> = {
  75. next() : IteratorResult<JavaMapEntry<any, any>> {
  76. if (iter.hasNext())
  77. return { value : iter.next(), done : false };
  78. return { value : null, done : true };
  79. }
  80. };
  81. return result;
  82. }
  83. }
  84. export function cast_de_nrw_schule_svws_core_adt_map_AVLMapSubEntrySet<K, V>(obj : unknown) : AVLMapSubEntrySet<K, V> {
  85. return obj as AVLMapSubEntrySet<K, V>;
  86. }