"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cast_de_nrw_schule_svws_core_adt_collection_LinkedCollectionIterator = exports.LinkedCollectionIterator = void 0;
const JavaObject_1 = require("../../../java/lang/JavaObject");
const ConcurrentModificationException_1 = require("../../../java/util/ConcurrentModificationException");
const NoSuchElementException_1 = require("../../../java/util/NoSuchElementException");
const UnsupportedOperationException_1 = require("../../../java/lang/UnsupportedOperationException");
class LinkedCollectionIterator extends JavaObject_1.JavaObject {
    _collection;
    _current = null;
    _expModCount;
    /**
     * Erzeugt einen neuen LinkedCollectionIterator. Dabei wird die Referenz auf
     * die {@link LinkedCollection} übergeben.
     *
     * @param collection   die zum Iterator zugehörige {@link LinkedCollection}
     */
    constructor(collection) {
        super();
        this._collection = collection;
        this._expModCount = collection._modCount;
        this._current = collection._head;
    }
    hasNext() {
        if (this._collection._modCount !== this._expModCount)
            throw new ConcurrentModificationException_1.ConcurrentModificationException();
        return (this._current !== null);
    }
    next() {
        if (this._collection._modCount !== this._expModCount)
            throw new ConcurrentModificationException_1.ConcurrentModificationException();
        if (this._current === null)
            throw new NoSuchElementException_1.NoSuchElementException();
        let result = this._current.getValue();
        this._current = this._current.getNext();
        return result;
    }
    remove() {
        throw new UnsupportedOperationException_1.UnsupportedOperationException("remove");
    }
    isTranspiledInstanceOf(name) {
        return ['java.util.Iterator', 'de.nrw.schule.svws.core.adt.collection.LinkedCollectionIterator'].includes(name);
    }
}
exports.LinkedCollectionIterator = LinkedCollectionIterator;
function cast_de_nrw_schule_svws_core_adt_collection_LinkedCollectionIterator(obj) {
    return obj;
}
exports.cast_de_nrw_schule_svws_core_adt_collection_LinkedCollectionIterator = cast_de_nrw_schule_svws_core_adt_collection_LinkedCollectionIterator;
//# sourceMappingURL=LinkedCollectionIterator.js.map