chengf
2026-01-27 b6184e2ddf3db37a94f7efb3b619bbc64642a292
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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 + "-";
    }
 
 
}