Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVRO-4066: Use JDK isBlank Method #3182

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public static String mangleMethod(String word, boolean isError) {
* Utility for template use. Adds a dollar sign to reserved words.
*/
public static String mangle(String word, Set<String> reservedWords, boolean isMethod) {
if (isBlank(word)) {
if (word == null || word.isBlank()) {
return word;
}
if (word.contains(".")) {
Expand Down Expand Up @@ -354,21 +354,6 @@ protected static String unmangle(String word) {
return word;
}

private static boolean isBlank(CharSequence cs) {
int strLen = cs == null ? 0 : cs.length();
if (strLen == 0) {
return true;
} else {
for (int i = 0; i < strLen; ++i) {
if (!Character.isWhitespace(cs.charAt(i))) {
return false;
}
}

return true;
}
}

/** Return the class that implements a schema, or null if none exists. */
public Class getClass(Schema schema) {
switch (schema.getType()) {
Expand Down Expand Up @@ -452,7 +437,7 @@ private Class getWrapper(Schema schema) {
public static String getClassName(Schema schema) {
String namespace = schema.getNamespace();
String name = schema.getName();
if (namespace == null || "".equals(namespace))
if (namespace == null || namespace.isEmpty())
return name;
String dot = namespace.endsWith("$") ? "" : "."; // back-compatibly handle $
return mangle(namespace) + dot + mangleTypeIdentifier(name);
Expand Down
Loading