MCPcopy Index your code
hub / github.com/astonbitecode/j4rs / java_map

Method java_map

rust/src/api/mod.rs:715–745  ·  view source on GitHub ↗

Creates a new Java Map with keys of class `key_class_name` and values of class `value_class_name`.

(
        &self,
        key_class_name: impl Into<&'a str>,
        value_class_name: impl Into<&'a str>,
        inv_args: HashMap<
            impl TryInto<InvocationArg, Error = J4RsError>,
      

Source from the content-addressed store, hash-verified

713
714 /// Creates a new Java Map with keys of class `key_class_name` and values of class `value_class_name`.
715 pub fn java_map<'a>(
716 &self,
717 key_class_name: impl Into<&'a str>,
718 value_class_name: impl Into<&'a str>,
719 inv_args: HashMap<
720 impl TryInto<InvocationArg, Error = J4RsError>,
721 impl TryInto<InvocationArg, Error = J4RsError>,
722 >,
723 ) -> errors::Result<Instance> {
724 let mut inv_args_results: Vec<Result<InvocationArg, J4RsError>> =
725 Vec::with_capacity(inv_args.len() * 2);
726 let mut i = 0;
727 let mut inv_args = inv_args;
728
729 for (key, val) in inv_args.drain() {
730 inv_args_results.insert(i, key.try_into());
731 i += 1;
732 inv_args_results.insert(i, val.try_into());
733 i += 1;
734 }
735 let inv_args: Result<Vec<InvocationArg>, J4RsError> = inv_args_results
736 .into_iter()
737 .map(|arg| arg.try_into())
738 .collect();
739 Self::do_create_java_map(
740 self.jni_env,
741 key_class_name.into(),
742 value_class_name.into(),
743 inv_args?.as_ref(),
744 )
745 }
746
747 fn do_create_java_map(
748 jni_env: *mut JNIEnv,

Callers 1

invoke_mapFunction · 0.80

Calls 2

collectMethod · 0.80
mapMethod · 0.80

Tested by 1

invoke_mapFunction · 0.64