com.github.ankurpathak.util.Strings Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of username-validation Show documentation
Show all versions of username-validation Show documentation
Java library for username validation for general use
and with bean validation api.
package com.github.ankurpathak.util;
import java.util.Objects;
public class Strings {
public static final String BLANK = "";
public static boolean isBlank(String string){
return string == null || Objects.equals(string.trim(), BLANK);
}
public static Character firstChar(String string){
if(!isBlank(string)){
return string.charAt(0);
}else {
return null;
}
}
public static Character lastChar(String string){
if(!isBlank(string)){
return string.charAt(string.length() - 1);
}else {
return null;
}
}
}