feat(java_common): add ByteString overloads for fact value conversions
@@ -279,6 +279,7 @@ func generateJava(protoFile string, index *SchemaIndex) {
fmt.Fprintln(src, "import com.google.devtools.kythe.proto.Schema.FactName;")
fmt.Fprintln(src, "import com.google.devtools.kythe.proto.Schema.NodeKind;")
fmt.Fprintln(src, "import com.google.devtools.kythe.proto.Schema.Subkind;")
+ fmt.Fprintln(src, "import com.google.protobuf.ByteString;")
fmt.Fprintln(src, "/** Utility for handling schema strings and their corresponding protocol buffer enums. */")
fmt.Fprintln(src, "public final class Schema {")
@@ -315,9 +316,15 @@ func generateJava(protoFile string, index *SchemaIndex) {
fmt.Fprintln(src, "/** Returns the schema {@link NodeKind} for the given kind. */")
fmt.Fprintln(src, "public static NodeKind nodeKind(String k) { return NODE_KINDS.getOrDefault(k, NodeKind.UNKNOWN_NODE_KIND); }")
+ fmt.Fprintln(src, "/** Returns the schema {@link NodeKind} for the given kind. */")
+ fmt.Fprintln(src, "public static NodeKind nodeKind(ByteString k) { return nodeKind(k.toStringUtf8()); }")
+
fmt.Fprintln(src, "/** Returns the schema {@link Subkind} for the given kind. */")
fmt.Fprintln(src, "public static Subkind subkind(String k) { return SUBKINDS.getOrDefault(k, Subkind.UNKNOWN_SUBKIND); }")
+ fmt.Fprintln(src, "/** Returns the schema {@link Subkind} for the given kind. */")
+ fmt.Fprintln(src, "public static Subkind subkind(ByteString k) { return subkind(k.toStringUtf8()); }")
+
fmt.Fprintln(src, "/** Returns the schema {@link EdgeKind} for the given kind. */")
fmt.Fprintln(src, "public static EdgeKind edgeKind(String k) { return EDGE_KINDS.getOrDefault(k, EdgeKind.UNKNOWN_EDGE_KIND); }")
