All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.qt.core.QList Maven / Gradle / Ivy

There is a newer version: 6.8.0
Show newest version
/****************************************************************************
**
** Copyright (C) 2009-2024 Dr. Peter Droste, Omix Visualization GmbH & Co. KG. All rights reserved.
**
** This file is part of Qt Jambi.
**
** ** $BEGIN_LICENSE$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
** 
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
** $END_LICENSE$

**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
package io.qt.core;

import java.util.Collection;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.function.Predicate;

import io.qt.NativeAccess;
import io.qt.QNoImplementationException;
import io.qt.QNoNativeResourcesException;
import io.qt.QtUninvokable;

/**
 * 

Java wrapper for Qt class QList

*/ public class QList extends AbstractList implements Cloneable { static { QtJambi_LibraryUtilities.initialize(); } /** * Constructor for internal use only. * @param p expected to be null. * @hidden */ @NativeAccess protected QList(QPrivateConstructor p) { super(p); } /** * Creating a container with given element type. *

See QList::QList()

* @param metaType the type T */ public QList(QMetaType.Type metaType) { this(new QMetaType(metaType)); } /** * Creating a container with given element type. *

See QList::QList()

* @param elementType the type T */ public QList(Class elementType) { super(null); QMetaType metaType = QMetaType.fromType(elementType); initialize(elementType, QtJambi_LibraryUtilities.internal.nativeId(metaType), null); } /** * Creating a container with given element type and size. *

See QList::QList()

* @param metaType the type T */ public QList(QMetaType metaType) { super(null); initialize(metaType.javaType(), QtJambi_LibraryUtilities.internal.nativeId(metaType), null); } /** * Creating a container with given element type and size. *

See QList::QList(qsizetype)

* @param metaType the type T */ public QList(QMetaType.Type metaType, int size) { this(new QMetaType(metaType), size); } /** * Creating a container with given element type and size. *

See QList::QList(qsizetype)

* @param elementType the type T */ public QList(Class elementType, int size) { this(QMetaType.fromType(elementType), size); } /** * Creating a container with given element type and size. *

See QList::QList(qsizetype)

* @param metaType the type T */ public QList(QMetaType metaType, int size) { this(metaType); resize(size); } /** * Creating a container filled with given value. *

See QList::QList(qsizetype,T)

*/ public QList(int size, T value) { this(findElementMetaType(value)); fill(value, size); } /** * Creating a container with given content. *

See QList::QList(const QList<T> &)

* @param other container */ public QList(Collection other) { super(null); QMetaType metaType = findElementMetaType(Objects.requireNonNull(other)); initialize(metaType.javaType(), QtJambi_LibraryUtilities.internal.nativeId(metaType), other); } @NativeAccess QList(QMetaType elementMetaType, Collection other) { super(null); initialize(elementMetaType.javaType(), QtJambi_LibraryUtilities.internal.nativeId(elementMetaType), other); } /** * Creating a container of type QVariant. */ public static QList createVariantList(){ return new QList<>(new QMetaType(QMetaType.Type.QVariant)); } /** * Creating a container of type QVariant and given size. */ public static QList createVariantList(int size){ return new QList<>(new QMetaType(QMetaType.Type.QVariant), size); } @QtUninvokable private native void initialize(Class elementType, long elementMetaType, Collection other); /** * Creates and returns a copy of this object. *

See QList::QList(const QList<T> &)

*/ @Override public QList clone(){ return new QList<>(this); } /** *

See QList::append(const QList<T> &)

*/ @QtUninvokable public final void append(java.util.Collection t) { appendList(QtJambi_LibraryUtilities.internal.nativeId(this), t); } @QtUninvokable private static native void appendList(long __this__nativeId, java.util.Collection t); /** *

See QList::append(T)

*/ @QtUninvokable public final void append(T t) { try { append(QtJambi_LibraryUtilities.internal.nativeId(this), t); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, elementMetaType(), t); } } @QtUninvokable private static native void append(long __this__nativeId, T t); /** *

See QList::at(qsizetype)const

*/ @QtUninvokable public final T at(int i) { return at(QtJambi_LibraryUtilities.internal.nativeId(this), i); } @QtUninvokable private static native T at(long __this__nativeId, int i); /** *

See QList::clear()

*/ @QtUninvokable public final void clear() { clear(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private static native void clear(long __this__nativeId); /** *

See QList::contains(T)const

*/ @QtUninvokable public final boolean contains(Object t) { try { return contains(QtJambi_LibraryUtilities.internal.nativeId(this), t); }catch(QNoNativeResourcesException e) { throw e; }catch(IllegalArgumentException e) { return false; }catch(RuntimeException e) { RuntimeException e1 = QSet.handleException(e, elementMetaType(), t); if(e1==e) throw e; return false; } } @QtUninvokable private static native boolean contains(long __this__nativeId, T t); /** *

See QList::count()const

*/ @QtUninvokable public final int count() { return size(); } /** *

See QList::count(T)const

*/ @QtUninvokable public final int count(T t) { try{ return count(QtJambi_LibraryUtilities.internal.nativeId(this), t); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, elementMetaType(), t); } } @QtUninvokable private static native int count(long __this__nativeId, T t); /** * Provides a mutable C++ iterator to the containers begin. *

See QList::begin()

* @return begin */ @QtUninvokable protected final QSequentialIterator begin() { return begin(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private static native QSequentialIterator begin(long __this__nativeId); /** * Provides a mutable C++ iterator to the containers end. *

See QList::end()

* @return end */ @QtUninvokable protected final QSequentialIterator end() { return end(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private static native QSequentialIterator end(long __this__nativeId); /** * Provides a constant C++ iterator to the containers begin. *

See QList::constBegin()const

* @return begin */ @QtUninvokable protected final QSequentialConstIterator constBegin() { return constBegin(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private static native QSequentialConstIterator constBegin(long __this__nativeId); /** * Provides a constant C++ iterator to the containers end. *

See QList::constEnd()const

* @return end */ @QtUninvokable protected final QSequentialConstIterator constEnd() { return constEnd(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private static native QSequentialConstIterator constEnd(long __this__nativeId); /** *

See QList::endsWith(T)const

*/ @QtUninvokable public final boolean endsWith(T t) { try{ return endsWith(QtJambi_LibraryUtilities.internal.nativeId(this), t); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, elementMetaType(), t); } } @QtUninvokable private static native boolean endsWith(long __this__nativeId, T t); /** *

See QList::first()const

*/ @QtUninvokable public final T first() { try { return at(0); } catch (IndexOutOfBoundsException e) { throw new NoSuchElementException(); } } /** *

See QList::indexOf(T,qsizetype)const

*/ @QtUninvokable public final int indexOf(T t, int from) { try { return indexOf(QtJambi_LibraryUtilities.internal.nativeId(this), t, from); }catch(QNoNativeResourcesException e) { throw e; }catch(IllegalArgumentException e) { return -1; }catch(RuntimeException e) { RuntimeException e1 = QSet.handleException(e, elementMetaType(), t); if(e1==e) throw e; return -1; } } @QtUninvokable private static native int indexOf(long __this__nativeId, T t, int from); /** *

See QList::insert(qsizetype,T)

*/ @QtUninvokable public final void insert(int i, T t) { insert(i, 1, t); } /** *

See QList::isEmpty()const

*/ @QtUninvokable public final boolean isEmpty() { return size()==0; } /** *

See QList::last()const

*/ @QtUninvokable public final T last() { try { return last(QtJambi_LibraryUtilities.internal.nativeId(this)); } catch (IndexOutOfBoundsException e) { throw new NoSuchElementException(); } } @QtUninvokable private static native T last(long __this__nativeId); /** *

See QList::lastIndexOf(T,qsizetype)const

*/ @SuppressWarnings("unchecked") @QtUninvokable @Override public final int lastIndexOf(Object t) { return lastIndexOf((T)t, (int)-1); } /** *

See QList::lastIndexOf(T,qsizetype)const

*/ @QtUninvokable public final int lastIndexOf(T t, int from) { try { return lastIndexOf(QtJambi_LibraryUtilities.internal.nativeId(this), t, from); }catch(QNoNativeResourcesException e) { throw e; }catch(IllegalArgumentException e) { return -1; }catch(RuntimeException e) { RuntimeException e1 = QSet.handleException(e, elementMetaType(), t); if(e1==e) throw e; return -1; } } @QtUninvokable private static native int lastIndexOf(long __this__nativeId, T t, int from); /** *

See QList::length()const

*/ @QtUninvokable public final int length() { return size(); } /** *

See QList::mid(qsizetype,qsizetype)const

*/ @QtUninvokable public final QList mid(int pos) { return mid(pos, (int)-1); } /** *

See QList::mid(qsizetype,qsizetype)const

*/ @QtUninvokable public final QList mid(int pos, int length) { return mid(QtJambi_LibraryUtilities.internal.nativeId(this), pos, length); } @QtUninvokable private static native QList mid(long __this__nativeId, int pos, int length); /** *

See QList::move(qsizetype,qsizetype)

*/ @QtUninvokable public final void move(int from, int to) { move(QtJambi_LibraryUtilities.internal.nativeId(this), from, to); } @QtUninvokable private static native void move(long __this__nativeId, int from, int to); /** *

See QList::prepend(T)

*/ @QtUninvokable public final void prepend(T t) { try { insert(QtJambi_LibraryUtilities.internal.nativeId(this), 0, 1, t); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, elementMetaType(), t); } } /** *

See QList::removeAll(T)

*/ @QtUninvokable public final int removeAll(T t) { try { return removeAll(QtJambi_LibraryUtilities.internal.nativeId(this), t); }catch(QNoNativeResourcesException e) { throw e; }catch(IllegalArgumentException e) { return 0; }catch(RuntimeException e) { RuntimeException e1 = QSet.handleException(e, elementMetaType(), t); if(e1==e) throw e; return 0; } } @QtUninvokable private static native int removeAll(long __this__nativeId, T t); /** *

See QList::removeIf(Predicate)

*/ @QtUninvokable public final boolean removeIf(Predicate predicate) { Objects.requireNonNull(predicate); boolean removed = false; for(T value : clone()) { if (predicate.test(value)) { removeAll(value); removed = true; } } return removed; } /** *

See QList::removeAt(qsizetype)

*/ @QtUninvokable public final void removeAt(int i) { remove(i, 1); } /** *

See QList::removeFirst()

*/ @QtUninvokable public final T removeFirst() { return takeFirst(); } /** *

See QList::removeLast()

*/ @QtUninvokable public final T removeLast() { return takeLast(); } /** *

See QList::removeOne(T)

*/ @QtUninvokable public final boolean removeOne(T t) { try { return removeOne(QtJambi_LibraryUtilities.internal.nativeId(this), t); }catch(QNoNativeResourcesException e) { throw e; }catch(IllegalArgumentException e) { }catch(RuntimeException e) { RuntimeException e1 = QSet.handleException(e, elementMetaType(), t); if(e1==e) throw e; } return false; } @QtUninvokable private static native boolean removeOne(long __this__nativeId, T t); /** *

See QList::replace(qsizetype,T)

*/ @QtUninvokable public final void replace(int i, T t) { try { replace(QtJambi_LibraryUtilities.internal.nativeId(this), i, t); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, elementMetaType(), t); } } @QtUninvokable private static native void replace(long __this__nativeId, int i, T t); /** *

See QList::reserve(qsizetype)

*/ @QtUninvokable public final void reserve(int size) { reserve(QtJambi_LibraryUtilities.internal.nativeId(this), size); } @QtUninvokable private static native void reserve(long __this__nativeId, int size); /** *

See QList::size()const

*/ @QtUninvokable public final int size() { return size(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private static native int size(long __this__nativeId); /** *

See QList::startsWith(T)const

*/ @QtUninvokable public final boolean startsWith(T t) { try{ return startsWith(QtJambi_LibraryUtilities.internal.nativeId(this), t); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, elementMetaType(), t); } } @QtUninvokable private static native boolean startsWith(long __this__nativeId, T t); /** *

See QList::takeAt(qsizetype)

*/ @QtUninvokable public final T takeAt(int i) { return takeAt(QtJambi_LibraryUtilities.internal.nativeId(this), i); } @QtUninvokable private static native T takeAt(long __this__nativeId, int i); /** *

See QList::takeFirst()

*/ @QtUninvokable public final T takeFirst() { try { return takeAt(0); } catch (IndexOutOfBoundsException e) { throw new NoSuchElementException(); } } /** *

See QList::takeLast()

*/ @QtUninvokable public final T takeLast() { try{ return takeLast(QtJambi_LibraryUtilities.internal.nativeId(this)); } catch (IndexOutOfBoundsException e) { throw new NoSuchElementException(); } } @QtUninvokable private static native T takeLast(long __this__nativeId); /** *

See QList::value(qsizetype)

*/ @QtUninvokable public final T value(int i) { return value(QtJambi_LibraryUtilities.internal.nativeId(this), i); } @QtUninvokable private static native T value(long __this__nativeId, int i); /** *

See QList::value(qsizetype,T)

*/ @QtUninvokable public final T value(int i, T defaultValue) { try { return valueDefault(QtJambi_LibraryUtilities.internal.nativeId(this), i, defaultValue); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, elementMetaType(), defaultValue); } } @QtUninvokable private static native T valueDefault(long __this__nativeId, int i, T defaultValue); /** *

See QList::operator==(QList<T>)const

*/ @Override @QtUninvokable public boolean equals(Object other) { if(other instanceof StackDeque) { other = ((StackDeque)other).stack; } if (other instanceof java.util.Collection && checkContainerType(this.elementMetaType(), (java.util.Collection) other)) { return operator_equal(QtJambi_LibraryUtilities.internal.nativeId(this), (java.util.Collection) other); } return false; } @QtUninvokable private static native boolean operator_equal(long __this__nativeId, java.util.Collection l); /** * Returns the objects's hash code computed by qHash(QList<T>). */ @Override @QtUninvokable public int hashCode() { try { return hashCode(QtJambi_LibraryUtilities.internal.nativeId(this)); } catch (QNoNativeResourcesException e) { return 0; } } @QtUninvokable private static native int hashCode(long __this__nativeId); /** * Returns the string representation of the object given by QVariant(this).toString(). */ @Override @QtUninvokable public String toString() { try { return toString(QtJambi_LibraryUtilities.internal.nativeId(this)); } catch (QNoImplementationException e) { return super.toString(); } catch (QNoNativeResourcesException e) { return "null"; } } @QtUninvokable private static native String toString(long __this__nativeId); /** * Appends the specified element to the end of this list. * @see List#add(Object) */ @Override @QtUninvokable public boolean add(T e){ append(e); return true; } /** * Inserts the specified element at the specified position in this list. * @see List#add(int, Object) */ @Override @QtUninvokable public final void add(int index, T e){ insert(index, e); } /** * Replaces the element at the specified position in this list with the * specified element. * @see List#set(int, Object) */ @Override @QtUninvokable public final T set(int index, T e){ if(e!=null){ T el = at(index); replace(index, e); return el; } else return null; } /** * Removes the first occurrence of the specified element from this list, * if it is present. * @see List#remove(Object) */ @SuppressWarnings("unchecked") @Override @QtUninvokable public final boolean remove(Object e){ return removeOne((T)e); } /** *

See QList::indexOf(T,qsizetype)const

*/ @SuppressWarnings("unchecked") @Override @QtUninvokable public final int indexOf(Object e){ return indexOf((T)e, (int)0); } /** * Returns the element at the specified position in this list. * @see List#get(int) */ @Override @QtUninvokable public final T get(int index) { return at(index); } /** *

See QList::swapItemsAt(qsizetype,qsizetype)

*/ @QtUninvokable public final void swapItemsAt(int i, int j) { swapItemsAt(QtJambi_LibraryUtilities.internal.nativeId(this), i, j); } @QtUninvokable private static native void swapItemsAt(long __this__nativeId, int i, int j); /** *

See QList::fill(T,qsizetype)

*/ @QtUninvokable public final void fill(T t) { fill(t, (int)-1); } /** *

See QList::fill(T,qsizetype)

*/ @QtUninvokable public final void fill(T t, int size) { try { fill(QtJambi_LibraryUtilities.internal.nativeId(this), t, size); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, elementMetaType(), t); } } @QtUninvokable private static native void fill(long __this__nativeId, T t, int size); /** *

See QList::insert(qsizetype,qsizetype,T)

*/ @QtUninvokable public final void insert(int i, int n, T t) { try { insert(QtJambi_LibraryUtilities.internal.nativeId(this), i, n, t); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, elementMetaType(), t); } } @QtUninvokable private static native void insert(long __this__nativeId, int i, int n, T t); /** *

See QList::remove(qsizetype,qsizetype)

*/ @QtUninvokable public final void remove(int i, int n) { remove(QtJambi_LibraryUtilities.internal.nativeId(this), i, n); } @QtUninvokable private static native void remove(long __this__nativeId, int i, int n); /** *

See QList::capacity()const

*/ @QtUninvokable public final int capacity() { return capacity(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private static native int capacity(long __this__nativeId); /** *

See QList::resize(qsizetype)

*/ @QtUninvokable public final void resize(int size) { resize(QtJambi_LibraryUtilities.internal.nativeId(this), size); } @QtUninvokable private static native void resize(long __this__nativeId, int size); /** *

See QList::squeeze()

*/ @QtUninvokable public final void squeeze() { squeeze(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private static native void squeeze(long __this__nativeId); /** *

See operator<<(QDataStream&,QList<T>)

*/ @io.qt.QtUninvokable public void writeTo(io.qt.core.QDataStream stream){ writeTo(QtJambi_LibraryUtilities.internal.nativeId(this), QtJambi_LibraryUtilities.internal.nativeId(stream)); } @io.qt.QtUninvokable private native void writeTo(long __this__nativeId, long stream); /** *

See operator>>(QDataStream&,QList<T>&)

*/ @io.qt.QtUninvokable public void readFrom(io.qt.core.QDataStream stream){ readFrom(QtJambi_LibraryUtilities.internal.nativeId(this), QtJambi_LibraryUtilities.internal.nativeId(stream)); } @io.qt.QtUninvokable private native void readFrom(long __this__nativeId, long stream); @io.qt.QtUninvokable final QMetaType elementMetaType() { return elementMetaType(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private static native QMetaType elementMetaType(long __this_nativeId); /** * Returns a QList containing given elements. * * @param the {@code QList}'s element type * @param element0 the first element * @param elements subsequent elements * @return a {@code QList} containing the specified element * @throws NullPointerException if elements are {@code null} * */ @SuppressWarnings({ "unchecked" }) @SafeVarargs public static QList of(T element0, T...elements) { QMetaType metaType = findElementMetaType(element0, elements); QList result; if(metaType.id()==QMetaType.Type.QString.value()) result = (QList)(QList)new QStringList(); else result = new QList<>(metaType); result.reserve(elements.length+1); result.append(element0); for (T t : elements) { result.append(t); } return result; } /** * Returns a QStringList containing given elements. * * @param the {@code QStringList}'s element type * @param element0 the first element * @param elements subsequent elements * @return a {@code QStringList} containing the specified element */ @SafeVarargs public static QStringList of(String element0, String...elements) { QStringList result = new QStringList(); result.reserve(elements.length+1); result.append(element0); for (String element : elements) { result.append(element); } return result; } static String pairPrefix() { return "std::pair"; } static boolean checkContainerType(QMetaType elementType, java.util.Collection container) { if (container instanceof QList && elementType.equals(((QList) container).elementMetaType())) { return true; } else if (container instanceof QSet && elementType.equals(((QSet) container).elementMetaType())) { return true; } else { Class type = elementType.javaType(); if (type.isPrimitive()) { if (type == int.class) type = Integer.class; if (type == short.class) type = Short.class; if (type == byte.class) type = Byte.class; if (type == long.class) type = Long.class; if (type == float.class) type = Float.class; if (type == double.class) type = Double.class; if (type == boolean.class) type = Boolean.class; if (type == char.class) type = Character.class; } for (Object entry : container) { if (entry != null && !type.isInstance(entry)) return false; } } return true; } @SafeVarargs static QMetaType findElementMetaType(Object element0, Object... elements){ QMetaType result = getMetaType(element0); Class type = element0==null ? null : QtJambi_LibraryUtilities.internal.getClass(element0); for(Object e : elements) { if(result!=null) { QMetaType _result = getMetaType(e); if(!result.isValid() || result.id()==QMetaType.Type.Nullptr.value()) result = _result; if(!_result.equals(result)) { result = null; } } if(e!=null) { if(type==null) { type = QtJambi_LibraryUtilities.internal.getClass(e); }else { Class type2 = QtJambi_LibraryUtilities.internal.getClass(e); if(type2!=type) { if(type2.isAssignableFrom(type)) { type = type2; }else if(!type.isAssignableFrom(type2)) { do{ type = type.getSuperclass(); }while(!type.isAssignableFrom(type2)); } } } } } if(result==null) result = QMetaType.fromType(type); return result; } static QMetaType findElementMetaType(Collection elements){ Class cls = QtJambi_LibraryUtilities.internal.getClass(elements); if(cls==QList.class) { return ((QList)elements).elementMetaType(); }else if(cls==QQueue.class) { return ((QQueue)elements).elementMetaType(); }else if(cls==QStack.class) { return ((QStack)elements).elementMetaType(); }else if(cls==QSet.class) { return ((QSet)elements).elementMetaType(); }else { QMetaType result = new QMetaType(); Class type = null; for(Object e : elements) { if(result!=null) { QMetaType _result = getMetaType(e); if(!result.isValid() || result.id()==QMetaType.Type.Nullptr.value()) result = _result; if(!_result.equals(result)) { result = null; } } if(e!=null) { if(type==null) { type = QtJambi_LibraryUtilities.internal.getClass(e); }else { Class type2 = QtJambi_LibraryUtilities.internal.getClass(e); if(type2!=type) { if(type2.isAssignableFrom(type)) { type = type2; }else if(!type.isAssignableFrom(type2)) { do{ type = type.getSuperclass(); }while(!type.isAssignableFrom(type2)); } } } } } if(result==null) result = QMetaType.fromType(type); return result; } } static QMetaType getMetaType(Object obj){ if(obj==null) return new QMetaType(QMetaType.Type.Nullptr); Class objClass = QtJambi_LibraryUtilities.internal.getClass(obj); if(objClass==QList.class) { return QMetaType.fromType(QList.class, ((QList)obj).elementMetaType()); }else if(objClass==QQueue.class) { return QMetaType.fromType(QQueue.class, ((QQueue)obj).elementMetaType()); }else if(objClass==QStack.class) { return QMetaType.fromType(QStack.class, ((QStack)obj).elementMetaType()); }else if(objClass==QSet.class) { return QMetaType.fromType(QSet.class, ((QSet)obj).elementMetaType()); }else if(objClass==QMultiMap.class) { return QMetaType.fromType(QMultiMap.class, ((QMultiMap)obj).keyMetaType(), ((QMultiMap)obj).valueMetaType()); }else if(objClass==QMap.class) { return QMetaType.fromType(QMap.class, ((QMap)obj).keyMetaType(), ((QMap)obj).valueMetaType()); }else if(objClass==QMultiHash.class) { return QMetaType.fromType(QMultiHash.class, ((QMultiHash)obj).keyMetaType(), ((QMultiHash)obj).valueMetaType()); }else if(objClass==QHash.class) { return QMetaType.fromType(QHash.class, ((QHash)obj).keyMetaType(), ((QHash)obj).valueMetaType()); }else if(objClass==QPair.class) { return QMetaType.fromType(QPair.class, getMetaType(((QPair)obj).first), getMetaType(((QPair)obj).second)); }else if(obj instanceof java.util.List) { java.util.List list = (java.util.List)obj; QMetaType elementMetaType = findElementMetaType(list); if(elementMetaType.isValid()) { return QMetaType.fromType(QList.class, elementMetaType); } }else if(obj instanceof java.util.Set) { java.util.Set list = (java.util.Set)obj; QMetaType elementMetaType = findElementMetaType(list); if(elementMetaType.isValid()) { return QMetaType.fromType(QSet.class, elementMetaType); } }else if(obj instanceof java.util.Map) { java.util.Map map = (java.util.Map)obj; QPair metaTypes = QMap.findMapMetaType(map); if(metaTypes.first.isValid() && metaTypes.second.isValid()) { if(obj instanceof java.util.NavigableMap) return QMetaType.fromType(QMap.class, metaTypes.first, metaTypes.second); else return QMetaType.fromType(QHash.class, metaTypes.first, metaTypes.second); } } QMetaType metaType = QMetaType.fromType(objClass); return metaType; } }