1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package net.lab1024.smartadmin.util;
- import org.apache.commons.lang3.StringUtils;
- import java.net.URISyntaxException;
- import java.util.List;
- import java.util.Map;
- import java.util.Set;
- public class SmartCommonUtils {
- public static String getWebRootPath(String filePath) {
- try {
- String path = SmartCommonUtils.class.getClassLoader().getResource("").toURI().getPath();
- path = path.replace("/WEB-INF/classes/", "");
- path = path.replace("/target/classes/", "");
- path = path.replace("file:/", "");
- if (StringUtils.isEmpty(filePath)) {
- return path;
- } else {
- return path + "/" + filePath;
- }
- } catch (URISyntaxException e) {
- throw new RuntimeException(e);
- }
- }
- public static boolean isEmpty(Object o) {
- if (o == null) {
- return true;
- } else {
- if (o instanceof String) {
- if (o.toString().trim().equals("")) {
- return true;
- }
- } else if (o instanceof List) {
- if (((List)o).size() == 0) {
- return true;
- }
- } else if (o instanceof Map) {
- if (((Map)o).size() == 0) {
- return true;
- }
- } else if (o instanceof Set) {
- if (((Set)o).size() == 0) {
- return true;
- }
- } else if (o instanceof Object[]) {
- if (((Object[])((Object[])o)).length == 0) {
- return true;
- }
- } else if (o instanceof int[]) {
- if (((int[])((int[])o)).length == 0) {
- return true;
- }
- } else if (o instanceof long[] && ((long[])((long[])o)).length == 0) {
- return true;
- }
- return false;
- }
- }
- }
|