summaryrefslogtreecommitdiff
path: root/platform/android/src/style/conversion/property_value.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/src/style/conversion/property_value.hpp')
-rw-r--r--platform/android/src/style/conversion/property_value.hpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/platform/android/src/style/conversion/property_value.hpp b/platform/android/src/style/conversion/property_value.hpp
new file mode 100644
index 0000000000..4121192f3f
--- /dev/null
+++ b/platform/android/src/style/conversion/property_value.hpp
@@ -0,0 +1,38 @@
+#pragma once
+
+#include <mbgl/style/property_value.hpp>
+#include "../../conversion/conversion.hpp"
+#include "../../conversion/constant.hpp"
+#include "types.hpp"
+#include "function.hpp"
+
+namespace mbgl {
+namespace android {
+namespace conversion {
+
+template <class T>
+struct Converter<jni::jobject*, mbgl::style::PropertyValue<T>> {
+
+ Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::PropertyValue<T>& value) const {
+
+ if(value.isUndefined()) {
+ //Return a nullptr representing a Java null value
+ return {nullptr};
+ } else if (value.isConstant()) {
+ //Time to convert the constant value
+ Result<jni::jobject*> result = convert<jni::jobject*, T>(env, value.asConstant());
+ return {*result};
+ //return converted;
+ } else if (value.isFunction()) {
+ //Must be a function than
+ return convert<jni::jobject*, mbgl::style::Function<T>>(env, value.asFunction());
+ } else {
+ throw std::runtime_error("Unknown property value type");
+ }
+
+ }
+};
+
+} // namespace conversion
+} // namespace android
+} // namespace mbgl \ No newline at end of file