1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | package Torello.Java.Additional; import Torello.Java.ReadOnly.ReadOnlyList; import java.util.stream.Stream; class AllNames { @SuppressWarnings("unchecked") static Stream<String> getAllFieldNames( final ReadOnlyList<Integer> allFieldReferences, final ReadOnlyList<Object> values ) { return allFieldReferences // Begins as a Torello.Java.ReadOnly.ReadOnlyList<Integer> of Constant-Table Indices // Convert the List into a Standard Java Stream<Integer> .stream() // Stream<Ret2<Integer, Integer>> : a Stream of Field-References // (pair of Table-Indices). // // Index-1: Constant-Table Index/Pointer to the Owner/Definer Class of a Field // Index-2: Table Pointer/Index to a "Name-And-Type". This is a Pair of Integers. // The Integer-Index-Pair points to the name and the type of the Field .map((Integer n) -> (Ret2<Integer, Integer>) values.get(n)) // Stream<Ret2<Integer, Integer>> : a Stream of Name-And-Type References // (another pair of Table-Indices) // // Index-1: Table Pointer to a UTF-8 Constant-Table Entry that contains a UTF-8 // Character-Byte Array (a simple string). This is the "Name" of the Field. // Index-2: A Pointer to a Class-Constant. Not used in this method .map((Ret2<Integer, Integer> r2) -> (Ret2<Integer, Integer>) values.get(r2.b)) // Stream<Integer> : The UTF-8 Constant-Table Locations .map((Ret2<Integer, Integer> r2) -> r2.a) .sorted() .distinct() // Stream<String> : a Stream of the Field-Names! .map((Integer i) -> (String) values.get(i)) .sorted() .distinct(); } @SuppressWarnings("unchecked") static Stream<String> getAllMethodNames( final ReadOnlyList<Integer> allMethodReferences, final ReadOnlyList<Integer> allInterfaceMethodReferences, final ReadOnlyList<Object> values ) { // Concatenate all "Method-References" with all "Interface Method-References" // Afterwards, follow the exact same steps that were followed for "Fields" return Stream .concat( allMethodReferences.stream(), allInterfaceMethodReferences.stream() ) .sorted() // Because two lists were merged, a sort helps a little .distinct() // Many methods have both "Method-Ref" and an "Interface-Method-Ref" // This stuff here, is the identical code that is done inside "getAllFieldNames" .map((Integer n) -> (Ret2<Integer, Integer>) values.get(n)) .map((Ret2<Integer, Integer> r2) -> (Ret2<Integer, Integer>) values.get(r2.b)) .map((Ret2<Integer, Integer> r2) -> (String) values.get(r2.a)) .sorted() .distinct(); } } |