
cc.youchain.utils.Strings Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of utils Show documentation
Show all versions of utils Show documentation
YOUChain Common library in JAVA.
package cc.youchain.utils;
import java.util.List;
/**
* String utility functions.
*/
public class Strings {
private Strings() {}
public static String toCsv(List src) {
// return src == null ? null : String.join(", ", src.toArray(new String[0]));
return join(src, ", ");
}
public static String join(List src, String delimiter) {
return src == null ? null : String.join(delimiter, src.toArray(new String[0]));
}
public static String capitaliseFirstLetter(String string) {
if (string == null || string.length() == 0) {
return string;
} else {
return string.substring(0, 1).toUpperCase() + string.substring(1);
}
}
public static String lowercaseFirstLetter(String string) {
if (string == null || string.length() == 0) {
return string;
} else {
return string.substring(0, 1).toLowerCase() + string.substring(1);
}
}
public static String zeros(int n) {
return repeat('0', n);
}
public static String repeat(char value, int n) {
return new String(new char[n]).replace("\0", String.valueOf(value));
}
public static boolean isEmpty(String s) {
return s == null || s.length() == 0;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy