优化代码空字符串判断
parent
4a0037d128
commit
c4fc4abf7c
|
@ -24,6 +24,8 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
@ -405,12 +407,11 @@ public class PlayServiceImpl implements IPlayService {
|
|||
if (device == null) {
|
||||
return null;
|
||||
}
|
||||
String mediaServerId = device.getMediaServerId();
|
||||
MediaServerItem mediaServerItem;
|
||||
if (mediaServerId == null || "".equals(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
|
||||
if (ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
|
||||
mediaServerItem = mediaServerService.getMediaServerForMinimumLoad();
|
||||
} else {
|
||||
mediaServerItem = mediaServerService.getOne(mediaServerId);
|
||||
mediaServerItem = mediaServerService.getOne(device.getMediaServerId());
|
||||
}
|
||||
if (mediaServerItem == null) {
|
||||
logger.warn("点播时未找到可使用的ZLM...");
|
||||
|
|
|
@ -98,7 +98,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
|||
@Override
|
||||
public StreamInfo save(StreamProxyItem param) {
|
||||
MediaServerItem mediaInfo;
|
||||
if (param.getMediaServerId() == null || "".equals(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())){
|
||||
if (ObjectUtils.isEmpty(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())){
|
||||
mediaInfo = mediaServerService.getMediaServerForMinimumLoad();
|
||||
}else {
|
||||
mediaInfo = mediaServerService.getOne(param.getMediaServerId());
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
package com.genersoft.iot.vmp.utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class CollectionUtil {
|
||||
|
||||
public static <T> boolean contains(T[] array, final T element) {
|
||||
return array != null && Arrays.stream(array).anyMatch((x) -> {
|
||||
return ObjectUtils.nullSafeEquals(x, element);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package com.genersoft.iot.vmp.utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ObjectUtils {
|
||||
public static boolean nullSafeEquals(Object o1, Object o2) {
|
||||
if (o1 == o2) {
|
||||
return true;
|
||||
} else if (o1 != null && o2 != null) {
|
||||
if (o1.equals(o2)) {
|
||||
return true;
|
||||
} else {
|
||||
return o1.getClass().isArray() && o2.getClass().isArray() && arrayEquals(o1, o2);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean arrayEquals(Object o1, Object o2) {
|
||||
if (o1 instanceof Object[] && o2 instanceof Object[]) {
|
||||
return Arrays.equals((Object[])((Object[])o1), (Object[])((Object[])o2));
|
||||
} else if (o1 instanceof boolean[] && o2 instanceof boolean[]) {
|
||||
return Arrays.equals((boolean[])((boolean[])o1), (boolean[])((boolean[])o2));
|
||||
} else if (o1 instanceof byte[] && o2 instanceof byte[]) {
|
||||
return Arrays.equals((byte[])((byte[])o1), (byte[])((byte[])o2));
|
||||
} else if (o1 instanceof char[] && o2 instanceof char[]) {
|
||||
return Arrays.equals((char[])((char[])o1), (char[])((char[])o2));
|
||||
} else if (o1 instanceof double[] && o2 instanceof double[]) {
|
||||
return Arrays.equals((double[])((double[])o1), (double[])((double[])o2));
|
||||
} else if (o1 instanceof float[] && o2 instanceof float[]) {
|
||||
return Arrays.equals((float[])((float[])o1), (float[])((float[])o2));
|
||||
} else if (o1 instanceof int[] && o2 instanceof int[]) {
|
||||
return Arrays.equals((int[])((int[])o1), (int[])((int[])o2));
|
||||
} else if (o1 instanceof long[] && o2 instanceof long[]) {
|
||||
return Arrays.equals((long[])((long[])o1), (long[])((long[])o2));
|
||||
} else {
|
||||
return o1 instanceof short[] && o2 instanceof short[] && Arrays.equals((short[]) ((short[]) o1), (short[]) ((short[]) o2));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue