#pragma once #include #include namespace mbgl { namespace android { namespace java { namespace util { class List : private mbgl::util::noncopyable { public: static constexpr auto Name() { return "java/util/List"; }; template static jni::Local>> toArray(jni::JNIEnv& env, const jni::Object& list) { static auto& javaClass = jni::Class::Singleton(env); static auto toArray = javaClass.GetMethod> ()>(env, "toArray"); return jni::Local>>(env, list.Call(env, toArray).release()); }; }; class Arrays : private mbgl::util::noncopyable { public: static constexpr auto Name() { return "java/util/Arrays"; }; template static jni::Local> asList(jni::JNIEnv& env, const jni::Array>& array) { static auto& javaClass = jni::Class::Singleton(env); static auto asList = javaClass.GetStaticMethod(jni::Array>)>(env, "asList"); auto typeErasedArray = jni::Local>>(env, jni::NewLocal(env, array).release()); return javaClass.Call(env, asList, typeErasedArray); } }; class Set : private mbgl::util::noncopyable { public: static constexpr auto Name() { return "java/util/Set"; }; template static jni::Local>> toArray(jni::JNIEnv& env, const jni::Object& list) { static auto& javaClass = jni::Class::Singleton(env); static auto toArray = javaClass.GetMethod> ()>(env, "toArray"); return jni::Local>>(env, list.Call(env, toArray).release()); }; }; class Map : private mbgl::util::noncopyable { public: static constexpr auto Name() { return "java/util/Map"; }; class Entry : private mbgl::util::noncopyable { public: static constexpr auto Name() { return "java/util/Map$Entry"; }; template static jni::Local> getKey(jni::JNIEnv& env, const jni::Object& entry) { static auto& javaClass = jni::Class::Singleton(env); static auto method = javaClass.GetMethod ()>(env, "getKey"); return jni::Cast(env, jni::Class::Singleton(env), entry.Call(env, method)); } template static jni::Local> getValue(jni::JNIEnv& env, const jni::Object& entry) { static auto& javaClass = jni::Class::Singleton(env); static auto method = javaClass.GetMethod ()>(env, "getValue"); return jni::Cast(env, jni::Class::Singleton(env), entry.Call(env, method)); } }; }; void registerNative(jni::JNIEnv&); } // namespace util } // namespace java } // namespace android } // namespace mbgl