Add Formatter::join

Test: pass
Test: hidl_test
Bug: 32559427
Change-Id: I44e27ba9b2e0fef605c340ba0f70f40ef0e6f390
diff --git a/CompoundType.cpp b/CompoundType.cpp
index 19b1896..55c5568 100644
--- a/CompoundType.cpp
+++ b/CompoundType.cpp
@@ -603,14 +603,9 @@
         out.block([&] {
             out << "return java.util.Objects.hash(\n";
             out.indent(2, [&] {
-                bool first = true;
-                for (const auto &field : *mFields) {
-                    if (!first) {
-                        out << ", \n";
-                    }
-                    first = false;
+                out.join(mFields->begin(), mFields->end(), ", \n", [&] (const auto &field) {
                     out << "android.os.HidlSupport.deepHashCode(this." << field->name() << ")";
-                }
+                });
             });
             out << ");\n";
         }).endl().endl();