package com.java110.dto.importData; public class Vtil { public static String defaultValue(Object o) { return o == null ? "" : o.toString(); } public static Double defaultDouble(Object o) { return o == null || o.equals("") ? null : Double.parseDouble(defaultValue(o)); } public static Double defaultDoubleSplit(Object o) { return o == null || o.equals("") ? null : Double.parseDouble(defaultValue(o).split("/")[0]); } public static String defaultValue(Object o, String defaultValue) { return o == null ? defaultValue : o.toString(); } public static String defaultValueToNull(Object o) { return o == null || o.equals("") ? null : o.toString(); } public static String appendHyphenToRight(String str) { // 1. 判空:null 或 去除首尾空格后为空字符串,都视为"空" if (str == null || str.trim().isEmpty()) { return str; // 空值直接返回,保持原有状态(null还是空字符串) } // 2. 非空则右侧拼接"-" return str + "-"; } }