- if not jreturn_type.is_void then
- return_type = jreturn_type.to_nit_type
-
- if not return_type.is_complete then
- if jreturn_type.is_wrapped then
- java_class.imports.add return_type.mod.as(not null)
- else
- if comment_unknown_types then
- comment = "#"
- else
- return_type = jreturn_type.extern_name
- java_class.unknown_types.add(jreturn_type)
- end
- end
+ # Generate getter and setter to access an attribute, of field
+ private fun generate_getter_setter(java_class: JavaClass, java_id: String,
+ attribute: JavaAttribute)
+ do
+ var java_type = attribute.java_type
+ var nit_type = model.java_to_nit_type(java_type)
+
+ var nit_id = java_id
+ if attribute.is_static then nit_id = java_class.class_type.extern_name.to_snake_case + "_" + nit_id
+ nit_id = nit_id.to_nit_method_name
+ nit_id = java_class.nit_name_for(nit_id, [java_type], false, attribute.is_static)
+
+ var c = ""
+ if not nit_type.is_known and comment_unknown_types then c = "#"
+ if java_type.is_vararg then c = "#"
+
+ var recv
+ if attribute.is_static then
+ recv = java_class.class_type.java_full_name
+ else recv = "self"
+
+ # Tabulation
+ var t = "\t"
+ if attribute.is_static then t = ""
+ var ct = c+t
+
+ file_out.write """
+{{{t}}}# Java getter: {{{java_class.class_type.extern_equivalent}}}.{{{java_id}}}
+{{{ct}}}fun {{{nit_id}}}: {{{nit_type}}} in "Java" `{
+{{{ct}}} return {{{recv}}}.{{{java_id}}};
+{{{ct}}}`}
+
+{{{t}}}# Java setter: {{{java_class.class_type.extern_equivalent}}}.{{{java_id}}}
+{{{ct}}}fun {{{nit_id}}}=(value: {{{nit_type}}}) in "Java" `{
+{{{ct}}} {{{recv}}}.{{{java_id}}} = value;
+{{{ct}}}`}
+
+"""
+ end
+
+ # Generate getter and setter to access an attribute, of field
+ private fun generate_constructor(java_class: JavaClass, constructor: JavaConstructor, name: String)
+ do
+ var c = ""
+ var nit_params_s = ""
+ var java_params_s = ""
+
+ if constructor.params.not_empty then
+ var nit_params = new Array[String]
+ var java_params = new Array[String]
+ var param_id = 'a'
+ for java_type in constructor.params do
+
+ java_params.add "{java_type.param_cast}{param_id}"
+
+ var nit_type = model.java_to_nit_type(java_type)
+ nit_params.add "{param_id}: {nit_type}"
+ param_id = param_id.successor(1)
+
+ if not nit_type.is_known and comment_unknown_types then c = "#"
+ if java_type.is_vararg then c = "#"