All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.smilego.tenant.util.StringUtil Maven / Gradle / Ivy

package io.smilego.tenant.util;

import java.math.BigDecimal;
import java.util.Objects;

public class StringUtil {

    public static String objectToString(Object object){
        if(Objects.nonNull(object)) {
            return String.valueOf(object);
        }
        return "";
    }

    public static boolean isInteger(String value){
        try {
            Integer.parseInt(value);
        } catch(NumberFormatException e) {
            return false;
        } catch(NullPointerException e) {
            return false;
        }
        return true;
    }

    public static boolean isBoolean(String value){
        try {
            Boolean.parseBoolean(value);
        } catch(NullPointerException e) {
            return false;
        } catch(Exception e) {
            return false;
        }
        return true;
    }

    public static boolean isBigDecimal(String value){
        try {
            BigDecimal.valueOf(Double.valueOf(value));
        } catch(NullPointerException e) {
            return false;
        } catch(Exception e) {
            return false;
        }
        return true;
    }

    public static boolean isLong(String value){
        try {
            Long.valueOf(Long.valueOf(value));
        } catch(NullPointerException e) {
            return false;
        } catch(Exception e) {
            return false;
        }
        return true;
    }

    public static Boolean isNullOrBlank(String string) {
        return Objects.isNull(string) || string.trim().isEmpty();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy