docs 新增工具类注释

2.X
AprilWind 7 months ago
parent 94cb942305
commit 0548faa837

@ -18,6 +18,13 @@ public class ValidatorUtils {
private static final Validator VALID = SpringUtils.getBean(Validator.class);
/**
*
*
* @param object
* @param groups
* @throws ConstraintViolationException
*/
public static <T> void validate(T object, Class<?>... groups) {
Set<ConstraintViolation<T>> validate = VALID.validate(object, groups);
if (!validate.isEmpty()) {

@ -7,10 +7,10 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import org.dromara.common.core.utils.SpringUtils;
import org.dromara.common.core.utils.StringUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.dromara.common.core.utils.SpringUtils;
import org.dromara.common.core.utils.StringUtils;
import java.io.IOException;
import java.util.ArrayList;
@ -30,6 +30,13 @@ public class JsonUtils {
return OBJECT_MAPPER;
}
/**
* JSON
*
* @param object
* @return JSONnullnull
* @throws RuntimeException JSON
*/
public static String toJsonString(Object object) {
if (ObjectUtil.isNull(object)) {
return null;
@ -41,6 +48,15 @@ public class JsonUtils {
}
}
/**
* JSON
*
* @param text JSON
* @param clazz
* @param <T>
* @return null
* @throws RuntimeException IO
*/
public static <T> T parseObject(String text, Class<T> clazz) {
if (StringUtils.isEmpty(text)) {
return null;
@ -52,6 +68,15 @@ public class JsonUtils {
}
}
/**
*
*
* @param bytes
* @param clazz
* @param <T>
* @return null
* @throws RuntimeException IO
*/
public static <T> T parseObject(byte[] bytes, Class<T> clazz) {
if (ArrayUtil.isEmpty(bytes)) {
return null;
@ -63,6 +88,15 @@ public class JsonUtils {
}
}
/**
* JSON
*
* @param text JSON
* @param typeReference TypeReference
* @param <T>
* @return null
* @throws RuntimeException IO
*/
public static <T> T parseObject(String text, TypeReference<T> typeReference) {
if (StringUtils.isBlank(text)) {
return null;
@ -74,6 +108,13 @@ public class JsonUtils {
}
}
/**
* JSONDict
*
* @param text JSON
* @return DictJSONnull
* @throws RuntimeException IO
*/
public static Dict parseMap(String text) {
if (StringUtils.isBlank(text)) {
return null;
@ -88,6 +129,13 @@ public class JsonUtils {
}
}
/**
* JSONDict
*
* @param text JSON
* @return Dictnull
* @throws RuntimeException IO
*/
public static List<Dict> parseArrayMap(String text) {
if (StringUtils.isBlank(text)) {
return null;
@ -99,6 +147,15 @@ public class JsonUtils {
}
}
/**
* JSON
*
* @param text JSON
* @param clazz
* @param <T>
* @return
* @throws RuntimeException IO
*/
public static <T> List<T> parseArray(String text, Class<T> clazz) {
if (StringUtils.isEmpty(text)) {
return new ArrayList<>();

@ -65,6 +65,12 @@ public class RedisUtils {
consumer.accept(msg);
}
/**
*
*
* @param channelKey key
* @param msg
*/
public static <T> void publish(String channelKey, T msg) {
RTopic topic = CLIENT.getTopic(channelKey);
topic.publish(msg);

Loading…
Cancel
Save