diff --git a/src/main/java/software/amazon/awssdk/crt/iot/SubscriptionStatusEventType.java b/src/main/java/software/amazon/awssdk/crt/iot/SubscriptionStatusEventType.java index 81a003870..dbc704d84 100644 --- a/src/main/java/software/amazon/awssdk/crt/iot/SubscriptionStatusEventType.java +++ b/src/main/java/software/amazon/awssdk/crt/iot/SubscriptionStatusEventType.java @@ -5,6 +5,11 @@ package software.amazon.awssdk.crt.iot; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; + /** * The type of change to the state of a streaming operation subscription */ @@ -28,7 +33,35 @@ public enum SubscriptionStatusEventType { private final int type; - private SubscriptionStatusEventType(int value) { + SubscriptionStatusEventType(int value) { type = value; } + + + /** + * @return the native enum integer value associated with this Java enum value + */ + public int getValue() { + return type; + } + + /** + * Creates a Java SubscriptionStatusEventType enum value from a native integer value + * @param value native integer value to convert to a SubscriptionStatusEventType instance + * @return a SubscriptionStatusEventType value + */ + public static SubscriptionStatusEventType getEnumValueFromInteger(int value) { + SubscriptionStatusEventType enumValue = enumMapping.get(value); + if (enumValue != null) { + return enumValue; + } + throw new RuntimeException("Illegal SubscriptionStatusEventType"); + } + + private static Map buildEnumMapping() { + return Stream.of(SubscriptionStatusEventType.values()) + .collect(Collectors.toMap(SubscriptionStatusEventType::getValue, Function.identity())); + } + + private final static Map enumMapping = buildEnumMapping(); } diff --git a/src/main/resources/META-INF/native-image/software.amazon.awssdk/crt/aws-crt/jni-config.json b/src/main/resources/META-INF/native-image/software.amazon.awssdk/crt/aws-crt/jni-config.json index 554b31286..0fa76f5ad 100644 --- a/src/main/resources/META-INF/native-image/software.amazon.awssdk/crt/aws-crt/jni-config.json +++ b/src/main/resources/META-INF/native-image/software.amazon.awssdk/crt/aws-crt/jni-config.json @@ -1061,7 +1061,7 @@ "name": "software.amazon.awssdk.crt.iot.SubscriptionStatusEventType", "methods": [ { - "name": "", + "name": "getEnumValueFromInteger", "parameterTypes": [ "int" ] diff --git a/src/native/java_class_ids.c b/src/native/java_class_ids.c index fe808b48e..005bc1c03 100644 --- a/src/native/java_class_ids.c +++ b/src/native/java_class_ids.c @@ -2414,9 +2414,12 @@ static void s_cache_subscription_status_event_type_properties(JNIEnv *env) { subscription_status_event_type_properties.subscription_status_event_type_class = (*env)->NewGlobalRef(env, cls); - subscription_status_event_type_properties.constructor_method_id = (*env)->GetMethodID( - env, subscription_status_event_type_properties.subscription_status_event_type_class, "", "(I)V"); - AWS_FATAL_ASSERT(subscription_status_event_type_properties.constructor_method_id); + subscription_status_event_type_properties.get_enum_value_from_integer_method_id = (*env)->GetStaticMethodID( + env, + subscription_status_event_type_properties.subscription_status_event_type_class, + "getEnumValueFromInteger", + "(I)Lsoftware/amazon/awssdk/crt/iot/SubscriptionStatusEventType;"); + AWS_FATAL_ASSERT(subscription_status_event_type_properties.get_enum_value_from_integer_method_id); } struct java_subscription_status_event_properties subscription_status_event_properties; @@ -2454,11 +2457,11 @@ static void s_cache_streaming_operation_options_properties(JNIEnv *env) { AWS_FATAL_ASSERT(streaming_operation_options_properties.topic_field_id); streaming_operation_options_properties.incoming_publish_event_callback_field_id = - (*env)->GetFieldID(env, cls, "incomingPublishEventCallback", "Ljava.util.function.Consumer;"); + (*env)->GetFieldID(env, cls, "incomingPublishEventCallback", "Ljava/util/function/Consumer;"); AWS_FATAL_ASSERT(streaming_operation_options_properties.incoming_publish_event_callback_field_id); streaming_operation_options_properties.subscription_status_event_callback_field_id = - (*env)->GetFieldID(env, cls, "subscriptionStatusEventCallback", "Ljava.util.function.Consumer;"); + (*env)->GetFieldID(env, cls, "subscriptionStatusEventCallback", "Ljava/util/function/Consumer;"); AWS_FATAL_ASSERT(streaming_operation_options_properties.subscription_status_event_callback_field_id); } diff --git a/src/native/java_class_ids.h b/src/native/java_class_ids.h index 73e4b99a3..708d74b7b 100644 --- a/src/native/java_class_ids.h +++ b/src/native/java_class_ids.h @@ -1010,7 +1010,7 @@ extern struct java_incoming_publish_event_properties incoming_publish_event_prop /* SubscriptionStatusEventType */ struct java_subscription_status_event_type_properties { jclass subscription_status_event_type_class; - jmethodID constructor_method_id; + jmethodID get_enum_value_from_integer_method_id; }; extern struct java_subscription_status_event_type_properties subscription_status_event_type_properties;