+
+ private fun extern_class_name: Array[String]
+ do
+ var class_name = new Array[String]
+ class_name.add(self.id)
+
+ if not self.has_generic_params then return class_name
+
+ class_name.add "Of"
+
+ for param in generic_params do class_name.add_all param.extern_class_name
+
+ return class_name
+ end
+
+ # Search inside `lib/android` directory for already wrapped classes
+ # If found, contains the class identifier and the Nit Module name
+ var find_extern_class: nullable Couple[String, NitModule] = find_extern_class_fun is lazy
+
+ private fun find_extern_class_fun: nullable Couple[String, NitModule]
+ do
+ var regex = "extern class Native[a-zA-Z1-9]\\\+[ ]\\\+in[ ]\\\+\"Java\"[ ]*`\{[ ]*" + self.to_s + "\\\+[ ]*`\}"
+ var grep = new IProcess("grep", "-r", regex, "{"NIT_DIR".environ}/lib/android/")
+ var to_eat = ["private", "extern", "class"]
+
+ var output = grep.read_line
+
+ var output_class = output.substring_from(output.index_of(':') + 1)
+ var tokens = output_class.split(" ")
+
+ var nclass_name = ""
+
+ for token in tokens do
+ if to_eat.has(token) then continue
+ nclass_name = token
+ break
+ end
+
+ if nclass_name == "" then return null
+
+ var str = output.substring(0, output.search(".nit").from)
+ str = str.substring_from(str.last_index_of('/') + 1)
+ var mod = new NitModule(str)
+
+ return new Couple[String, NitModule](nclass_name, mod)
+ end
+
+ # Comparison based on fully qualified named and generic params
+ # Ignores primitive array so `a.b.c[][] == a.b.c`
+ redef fun ==(other)
+ do
+ if other isa JavaType then
+ return self.repr == other.repr
+ end
+ return false
+ end
+
+ redef fun hash do return self.repr.hash
+
+ private fun repr: String
+ do
+ var id = self.full_id
+
+ if self.has_generic_params then
+ var gen_list = new Array[String]
+
+ for param in generic_params do
+ gen_list.add(param.to_s)
+ end
+
+ id += "<{gen_list.join(", ")}>"
+ end
+
+ return id
+ end
+
+ fun collections_list: Array[String] is cached do return ["List", "ArrayList", "LinkedList", "Vector", "Set", "SortedSet", "HashSet", "TreeSet", "LinkedHashSet", "Map", "SortedMap", "HashMap", "TreeMap", "Hashtable", "LinkedHashMap"]
+ fun iterable: Array[String] is cached do return ["ArrayList", "Set", "HashSet", "LinkedHashSet", "LinkedList", "Stack", "TreeSet", "Vector"]
+ fun maps: Array[String] is cached do return ["Map", "SortedMap", "HashMap", "TreeMap", "Hashtable", "LinkedHashMap"]