forked from fanruan/finekit
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
package com.fanruan.api.util; |
|
|
|
import com.fr.general.GeneralUtils; |
|
import org.jetbrains.annotations.NotNull; |
|
import org.jetbrains.annotations.Nullable; |
|
|
|
import java.io.IOException; |
|
|
|
/** |
|
* @author richie |
|
* @version 10.0 |
|
* Created by richie on 2019-08-09 |
|
*/ |
|
public class GeneralKit { |
|
|
|
/** |
|
* 返回系统的首选MAC地址 |
|
* |
|
* @return 表示系统MAC地址的字符串 |
|
*/ |
|
public static @NotNull String getMacAddress() throws IOException { |
|
return GeneralUtils.getMacAddress(); |
|
} |
|
|
|
/** |
|
* 任意对象转换为文本值 |
|
* @param obj 待转换的对象 |
|
* @return 文本值 |
|
*/ |
|
public static @NotNull String objectToString(Object obj) { |
|
return GeneralUtils.objectToString(obj); |
|
} |
|
|
|
/** |
|
* 任意对象转换为数值,如果无法转换为数值,就返回0 |
|
* @param obj 待转换的对象 |
|
* @return 数值 |
|
*/ |
|
public static @NotNull Number objectToNumber(Object obj) { |
|
return GeneralUtils.objectToNumber(obj); |
|
} |
|
|
|
/** |
|
* 任意对象转换为数值,如果无法转换为数值,根据returnNull参数决定,返回0或者返回null |
|
* @param obj 待转换的对象 |
|
* @param returnNull 无法转换时,是否返回null |
|
* @return 数值对象或者null |
|
*/ |
|
public static @Nullable Number objectToNumber(Object obj, boolean returnNull) { |
|
return GeneralUtils.objectToNumber(obj, returnNull); |
|
} |
|
}
|
|
|