Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 0ec725b

Browse files
committed
Pull getUnqualifiedName into a static helper function
Change-Id: Iacef70723df560273fef94aacb85c7f6a4819bc3
1 parent 3fee7c3 commit 0ec725b

2 files changed

Lines changed: 26 additions & 16 deletions

File tree

google-cloud-bigtable/clirr-ignored-differences.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,12 @@
355355
<className>com/google/cloud/bigtable/data/v2/models/sql/SqlType</className>
356356
<method>*enumOf(*)</method>
357357
</difference>
358+
<difference>
359+
<!-- InternalApi was added -->
360+
<differenceType>7012</differenceType>
361+
<className>com/google/cloud/bigtable/data/v2/models/sql/SqlType</className>
362+
<method>*getUnqualifiedName*</method>
363+
</difference>
358364
<difference>
359365
<!-- InternalApi was updated -->
360366
<differenceType>7004</differenceType>

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/SqlType.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,22 @@ static <T extends ProtocolMessageEnum> SqlType.Enum<T> enumOf(Function<Integer,
272272
return Type.Enum.create(method);
273273
}
274274

275+
/**
276+
* Extracts the unqualified name from a fully qualified proto message or enum name. For example,
277+
* "my.package.MyMessage" becomes "MyMessage".
278+
*
279+
* <p>This is considered an internal implementation detail and not meant to be used by
280+
* applications.
281+
*/
282+
@InternalApi
283+
static String getUnqualifiedName(String fullName) {
284+
if (fullName == null || fullName.isEmpty()) {
285+
return "";
286+
}
287+
int lastDotIndex = fullName.lastIndexOf('.');
288+
return (lastDotIndex == -1) ? fullName : fullName.substring(lastDotIndex + 1);
289+
}
290+
275291
/**
276292
* Creates a {@link SqlType} from the protobuf representation of Types.
277293
*
@@ -327,16 +343,6 @@ static SqlType<?> fromProto(com.google.bigtable.v2.Type proto) {
327343
*/
328344
@InternalApi
329345
static boolean typesMatch(SqlType<?> left, SqlType<?> right) {
330-
Function<String, String> getUnqualifiedMessageName =
331-
fullMessageName -> {
332-
if (fullMessageName == null || fullMessageName.isEmpty()) {
333-
return "";
334-
}
335-
int lastDotIndex = fullMessageName.lastIndexOf('.');
336-
return (lastDotIndex == -1)
337-
? fullMessageName
338-
: fullMessageName.substring(lastDotIndex + 1);
339-
};
340346
switch (left.getCode()) {
341347
case BYTES:
342348
case STRING:
@@ -359,9 +365,8 @@ static boolean typesMatch(SqlType<?> left, SqlType<?> right) {
359365
return left.equals(right);
360366
}
361367
// Compares mixed SchemalessProto and Proto
362-
return getUnqualifiedMessageName
363-
.apply(((SqlType.Proto) left).getMessageName())
364-
.equals(getUnqualifiedMessageName.apply(((SqlType.Proto) right).getMessageName()));
368+
return getUnqualifiedName(((SqlType.Proto) left).getMessageName())
369+
.equals(getUnqualifiedName(((SqlType.Proto) right).getMessageName()));
365370
}
366371
case ENUM:
367372
{
@@ -375,9 +380,8 @@ static boolean typesMatch(SqlType<?> left, SqlType<?> right) {
375380
return left.equals(right);
376381
}
377382
// Compares mixed SchemalessEnum and Enum
378-
return getUnqualifiedMessageName
379-
.apply(((SqlType.Enum) left).getEnumName())
380-
.equals(getUnqualifiedMessageName.apply(((SqlType.Enum) right).getEnumName()));
383+
return getUnqualifiedName(((SqlType.Enum) left).getEnumName())
384+
.equals(getUnqualifiedName(((SqlType.Enum) right).getEnumName()));
381385
}
382386
case STRUCT:
383387
// Don't validate fields since the field types will be validated on

0 commit comments

Comments
 (0)