Skip to content

Commit

Permalink
AVRO-4066: Use JDK isBlank Method
Browse files Browse the repository at this point in the history
  • Loading branch information
belugabehr committed Sep 28, 2024
1 parent 1a2d200 commit 9bebdd5
Showing 1 changed file with 2 additions and 17 deletions.
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

0 comments on commit 9bebdd5

Please sign in to comment.